vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   If statement based on page (https://vborg.vbsupport.ru/showthread.php?t=280735)

Jon12345 03-27-2012 04:55 PM

If statement based on page
 
I know vbulletin has if statements, which is all fine and dandy. But what about if you only want to run a bit of code based on the url of the page you are on. Is that possible?

e.g. if url contains forumsdisplay.php, then do such and such.

Thanks,

Jon

Pandemikk 03-27-2012 06:06 PM

THIS_SCRIPT constant will give you the script name of the page you are on.

For example, forumdisplay.php value is forumdisplay.

Jon12345 03-27-2012 06:18 PM

Does it let you use variables too?

e.g.
Code:

<if condition="THIS_SCRIPT == 'register.php?do=checkdate'"></if>

Pandemikk 03-27-2012 06:30 PM

If you want variables refer to the do branch.

You can also do request uri:

http://php.net/manual/en/reserved.variables.server.php

But this may be more unreliable.

Jon12345 03-27-2012 06:33 PM

What do you mean by referring to the do branch? :S

Edit: I've just looked at 'Do' Branch Naming in the vbulletin manual but can't seem to understand how this can help me check for a specific url with a specific variable.

vbenhancer 03-27-2012 07:10 PM

i can help you on this, but if you need private discussion/support for it, feel free to pm me with your code so i can teach you how to handle your data...

the if statement is not only adjustable in templates, but from the global calls as well... so if you want to change something from the register page, instead of calling a check/statement in the template as you seems to do right now, we can look at a more "php-like" verification for a better result.

Jon12345 03-28-2012 09:18 AM

That's kind of you vbenhancer. Actually, I think I am starting to understand this a little better, thanks to your guidance!

Lets take an example and perhaps someone can confirm if I have got this right or not. I am on mytemplate.php and I want to check for the value of a variable in the url. mytemplate.php?do=dog and mytemplate.php?do=cat

Here is my code:

Code:

if ($_POST['do'] == 'dog')
{
    // Run my javascript
}

if ($_POST['do'] == 'cat')
{
    // Run my javascript
}

Is that right? Or will that not run because it looks like raw php to me, rather than vbulletin code. Comments?


All times are GMT. The time now is 02:21 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.00987 seconds
  • Memory Usage 1,719KB
  • 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)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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