View Full Version : how do I call a plugin when 'new posts' is clicked but not when a search is performed
When a user goes to 'new posts' I want a plugin to execute when the new posts results are displayed. (The plugin displays some php generated text.)
But I don't want it to execute when the user performs a search and gets the results.
I see that the template 'search_resultlist' is used for new posts and search results.
I can call the plugin on this template but I don't know how to display it for only 'new posts'.
Is this possible and how can I do it?
Lynne
02-21-2012, 05:51 PM
Then do something regarding the do variable.
if ($_GET['do'] == 'getnew') ......
Hi Lynne
I'm not sure how to use the do variable.
When I perform a search the resulting URL is /search.php?searchid=3734120 which doesn't have a 'do' querystring.
To get this do variable I tried a couple ways ..
I created a plugin and wrote
print_r ($_GET);
and this writes the querystring on the page, which is
[searchid] => 3734147
And I added the following in the 'search_resultlist' template
<vb:if condition="$_GET['do'] == 'getnew'">Hello there!</vb:if>
But that didn't display the text 'Hello there!'
Maybe I'm placing the vb code in the wrong place or writing it incorrectly? I don't understand how to access the $_GET['do'] variable when its not in the URL.
Mark.B
02-21-2012, 11:30 PM
For a template conditional for getnew, in the template search_resultlist, you could use:
<vb:if condition="$criteriaDisplay == 'Type: Posts; New Posts'">
However, it's important to remember that your plugin code will still be running, even if the output is blocked by a template conditional. This could have load impacts for your server, and also page load speed.
In your plugin you could write:
if ($_GET['do'] == 'getnew')
{
/////Your plugin code here /////
}
Remember that if you're setting variables, you will also need to register them for use in the template. There's an article in the vB4 articles section about this.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.