vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Design and Graphics Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=253)
-   -   how do I call a plugin when 'new posts' is clicked but not when a search is performed (https://vborg.vbsupport.ru/showthread.php?t=278917)

30et 02-21-2012 04:52 AM

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') ......

30et 02-21-2012 09:57 PM

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

Code:

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

Code:

<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:
Code:

<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:
Code:

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.


All times are GMT. The time now is 10:28 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.01687 seconds
  • Memory Usage 1,714KB
  • 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
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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