vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Help with mod (https://vborg.vbsupport.ru/showthread.php?t=210618)

Ipuck 04-08-2009 01:25 AM

Help with mod
 
1 Attachment(s)
Hello

I'm trying to do a mod that replaced the "New Posts" link with "Posts and Threads".

When the link is press, a menu comes down showing 4 other links: New Posts, Today Post, New Threads, Unanswered Threads.

It works manually, but I wanted to share with others here and I wanted to make it a product.

If I upload the product to my site, it loads the template, add the menu to the page, but I cant make automatically replaced the "New Posts" link with "Posts and Threads".

I believe the problem is on the plugin, but I can't find it. I have tried 100 different ways and I can't make it work.

Here is the code:

PHP Code:


<?xml version="1.0" encoding="ISO-8859-1"?>
<product productid="posts_threads_menu" active="1">
    <title>Posts and Threads Navbar Menu</title>
      <description>Replace "New Posts" link with a dropdown menu that shows: New Posts, Today Post, New Threads, Unanswered Threads.</description> 
    <version>1.0</version>
    <versioncheckurl />
    <apm_author>iPuck</apm_author>
    <apm_relatedurl />
    <apm_extraedit />
      <dependencies>
          <dependency dependencytype="vbulletin" minversion="3.8" maxversion="" /> 
      </dependencies>
    <codes>
    </codes>
    <templates>
        <template name="navbar_posts_menu" templatetype="template" date="1223894172" username="iPuck" version="1.0">
<![CDATA[
<if condition="$show['popups'] AND $show['member']">
    <div class="vbmenu_popup" id="postsmenu_menu" style="display:none; margin-top:3px" align="$stylevar[left]">
        <table cellpadding="4" cellspacing="1" border="0">
            <tr><td class="thead">Posts & Threads</td></tr>
            <tr><td class="vbmenu_option"><a href="search.php?$session[sessionurl]do=getnew" accesskey="2">$vbphrase[new_posts_nav]</a></td></tr>
            <tr><td class="vbmenu_option"><a href="search.php?$session[sessionurl]do=getdaily">$vbphrase[todays_posts]</a></td></tr>
            <tr><td class="vbmenu_option"><a href="search.php?do=process&replyless=1&replylimit=100&exclude=0&nocache=0&sortby=threadstart">New Threads</a></td></td></tr>
            <tr><td class="vbmenu_option"><a href="search.php?do=process&replyless=1&replylimit=0&exclude=0&nocache=0">Unanswered Threads</a></td></td></tr>
        </table>
    </div>
</if>
]]>
        </template>
    </templates>
    <plugins>
        <plugin active="1" executionorder="5">
            <title>Posts and Threads Menu</title>
            <hookname>cache_templates</hookname>
            <phpcode>
<![CDATA[global $globaltemplates; $globaltemplates[] = 'navbar_posts_menu';]]>
            </phpcode>
        </plugin>

        <plugin active="1" executionorder="5">
            <title>Posts and Threads Menu</title>
            <hookname>parse_templates</hookname>
            <phpcode>
<![CDATA[$repl =array(
    array(
        '<td class=\"vbmenu_control\"><a href=\"search.php?$session[sessionurl]do=getnew\" accesskey=\"2\">$vbphrase[new_posts_nav]</a></td>',
        '<td id=\"postsmenu\" class=\"vbmenu_control\"><a href=\"search.php" . $GLOBALS[\'vbulletin\']->session->vars[\'sessionurl_q\'] . "\">Posts & Threads</a> <script type=\"text/javascript\"> vbmenu_register(\"postsmenu\"); </script></td>'
        ));
    foreach ($repl as $r)
        {
        $vbulletin->templatecache['navbar'] = str_replace($r[0],$r[1],$vbulletin->templatecache['navbar']);
        }
    unset($repl, $r);
        $vbulletin->templatecache['navbar'] = $vbulletin->templatecache['navbar'].$vbulletin->templatecache['navbar_posts_menu'];
]]>
            </phpcode>
        </plugin>
    </plugins>
    <phrases>
    </phrases>
    <options>
    </options>
    <helptopics>
    </helptopics>
    <cronentries>
    </cronentries>
    <faqentries>
    </faqentries>
</product>


TigerC10 04-08-2009 02:40 AM

One big problem that I see is in your array creation.

Code:

$repl =array(
    array(

You are making a 2 dimensional array. This is not necessary. Just take one of those out, and be sure to take out the matching parenthesis.

Next, you are searching for escaped quotes...

Code:

'<td class=\"vbmenu_control\">...
The only reason for escaping the quote symbol is if you START/END the string with a quote. You start the string with an apostrophe (see the blue ' at the beginning?).


So what you should do is either change the first/last apostrophe to a quote (") or get rid of all of the backslash escapes before the " in what you're looking for.

Ipuck 04-08-2009 04:28 AM

Thank you very much!

I'll try that.

--------------- Added [DATE]1239237177[/DATE] at [TIME]1239237177[/TIME] ---------------

Thanks TigerC10, but it didn't work.


All times are GMT. The time now is 03:11 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00948 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete