PDA

View Full Version : Help with mod


Ipuck
04-08-2009, 01:25 AM
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:



<?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.


$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...


'<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 1239237177 at 1239237177 ---------------

Thanks TigerC10, but it didn't work.