The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Using Variables Across Templates
I'm fairly sure what I am after is simple, I just don't know the best way to do it.
All I want to do it use a variable from the 'pagenav' template, in the 'SHOWTHREAD' template. That's it. I can see the variable is defined and then registered to the 'pagenav' template in functions.php. When I try to use the variable in the SHOWTHREAD template, it just shows blank. Any guidance would be awesome. Thanks, hilaryl |
#2
|
||||
|
||||
Well - you see it registered for the pagenav template, that's why it is available in the pagenav template.
It's not registered for showthread, so it's not. You can't use variables across templates in vB4. You need to properly register the variable. |
#3
|
||||
|
||||
Here is a link to a well written article on registering variables, https://vborg.vbsupport.ru/showthread.php?t=228078
|
#4
|
|||
|
|||
Thanks for your replies.
I've had a read through that article, and it makes sense in terms of creating a new variable for a template - but is there a way to use the variable from the pagenav template in the SHOWTHREAD template? I understand I will most likely need to create a plug-in for it - but I can't see how I assign one templates variable to a new variable, and then preregister that for a new template. Is that possible? |
#5
|
||||
|
||||
Without repeating the relevant code in a plugin, and generally speaking: no. Depending on the concrete case, there may be workarounds/dirty hacks.
|
#6
|
|||
|
|||
The main goal in this situation is to use the variables that generate the 'next/previous page' links to add rel="next" and rel="prev" into the <head>.
Purely for SEO purposes. I thought since these variables have already been created and used to ascertain whether there is a next page, it would make sense to just use them. Anyone know of another way I can get these next/prev tags working? |
#7
|
|||
|
|||
Just an update - I think I know a way I can create the links - but I'm having trouble using the '$thread_url' variable in a custom plugin.
It is defined and saved in showthread.php, as well as another variable '$url' which is registered right before it. I can use the '$url' variable in my plugin - but not the '$thread_url'. Any thoughts on that? As far as I can see they are both just strings - not sure why I can access one but not the other. The '$thread_url' just comes up blank when I try to use it. But if I use {vb:raw thread_url} in the template I can see exactly what I want to use in my plugin. Thoughts? |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|