Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-13-2015, 03:34 AM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 01-13-2015, 05:37 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 01-13-2015, 09:56 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is a link to a well written article on registering variables, https://vborg.vbsupport.ru/showthread.php?t=228078
Reply With Quote
  #4  
Old 01-13-2015, 10:27 PM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #5  
Old 01-14-2015, 05:10 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Without repeating the relevant code in a plugin, and generally speaking: no. Depending on the concrete case, there may be workarounds/dirty hacks.
Reply With Quote
  #6  
Old 01-14-2015, 09:47 PM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #7  
Old 01-15-2015, 10:58 PM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:20 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
  • Page Generation 0.04098 seconds
  • Memory Usage 2,213KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete