![]() |
calling a $_SERVER['REQUEST_URI'] within a template
I'm in the process of migrating from 3.0 to 4.0 setup of vBulletin. I've noticed that in 4.0, php tags do not work within the template files themselves. Hence it would seem that something like {vb:var variable_name} is the format I need to employ for what I'm trying to accomplish. I've got a custom login redirect that I'm working to implement. To do so, I need to call the equivalent of $_SERVER['REQUEST_URI'] within the template.
My question is does such a predefined variable exist? If not, is there an easy way to create this variable? Basically, what I am doing is sending a call to a login page which needs to know which page the user was on when the call was initiated. I've already spent several hours searching the forums and Google for a solution to no avail. I've also read through the Template Tags and Languages and Phrases section without much success. I'm completely new to the vBulletin environment, so any help would be appreciated. |
Here is a general solution:
Add this plugin code to init_startup (or any other plugin location occurring before your template is registered.) PHP Code:
|
Thanks Attilitus for your response,
However, I'm not seeing how this will allow me to use the php global variable $_SERVER['REQUEST_URI'] within a vBulletin template. Maybe, I'm missing something? Thank you. |
Your problem's solution is a special case of my general solution.
PHP Code:
|
Ok, that makes more sense. This leads to two more questions then. Where do I go to find a suitable plugin to tack this bit of code on to? I've got FTP access, I wouldn't even know wher to begin looking. Or, is this something that can be achieved from the control panel?
And then just to make sure I understand the syntax, in my template file, I'd use something like: {vb:raw $myarray['variable_name'] } Is that correct? Thanks again. |
No. As I explained in the first post:
Quote:
To add this: go into your admincp, and Add New Plugin. The location of the plugin should be init_start, and the plugin code should be what I posted here. Alternatively, since it sounds as if you have limited experience: you might wait for someone else to come along with alternative advice on how to solve your problem. (vBulletin might provide you server variables in templates already, I'm not sure.) ~Tim |
Thanks Tim again for your help,
I apologize for overlooking the second part of your first post. I think I've followed your instructions. However, I'm still in the dark. I've not been able to make your suggestion work, as far as I can tell. In the Add a New plugin section, I've followed your instruction as explained above, Here's the code that I created based off of what you suggested above: Code:
$server_vars=array(); The full line of html looks like this: Code:
<a rel="nofollow" href="/login/icslogin.php?destination={vb:var request_uri}">Register | Login</a> |
Quote:
My provided code will make the variable {vb:var variable_name} available in the template with name 'template_name'. If the template in which you are adding the variable is not named exactly 'template_name' then the variable will not be accessible from that template. Perhaps this is your problem: Note that once a template is parsed, all non-registered variables are removed from the template string. That is: If you have two templates: template1 and template2. Then suppose you render template1 and store it in variable var_template1, then put {vb:raw var_template1} in template2. Registering a variable for template2, will not allow you to use that variable in template1. |
Just to conclude this thread, here's the solution that worked for me. Attilitus was right on with his suggestions above below is the specific solution that worked for me:
In the Plugins Manager under the Plugins/Products menu, I created a new plugin, set the hook to init_startup and then used this line of code: PHP Code:
Thanks again for your help, Tim. -Brent |
All times are GMT. The time now is 06:48 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|