Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2009, 01:25 AM
Ipuck's Avatar
Ipuck Ipuck is offline
 
Join Date: Jun 2006
Location: California
Posts: 131
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help with mod

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>
Attached Files
File Type: xml posts_and_threads_prduct.xml (2.8 KB, 2 views)
Reply With Quote
  #2  
Old 04-08-2009, 02:40 AM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 04-08-2009, 04:28 AM
Ipuck's Avatar
Ipuck Ipuck is offline
 
Join Date: Jun 2006
Location: California
Posts: 131
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much!

I'll try that.

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

Thanks TigerC10, but it didn't work.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:46 PM.


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.04542 seconds
  • Memory Usage 2,216KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (1)postbit_attachment
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete