Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 04 Dec 2014, 20:41
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Real name: James
Template Variable Issue

Hey guys. Before proceeding, I have read http://www.vbulletin.org/forum/showthread.php?t=228078 and am still not sure what's up with my code.

First, I have this function which is based on a user profile field single select menu.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This and other functions are located in a folder on the server. I have added a plugin at the hook "global_bootstrap_init_start" with this code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I am now trying to create a code to output a template variable in postbit_legacy. This is the code I have for my plugin which is at the hook "process_templates_complete".


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Then I attempt t use {vb:raw ccimg} in the postbit_legacy template and nothing appears. Where am I going wrong? Thanks in advance.
Reply With Quote
  #2  
Old 04 Dec 2014, 20:48
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I think the first thing I'd do is to make sure that $imgoutput is set to something even if get_ccode returns null, just for testing. Maybe something like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


If it's still blank then at least you know that it's something to do with the templates.
Reply With Quote
  #3  
Old 04 Dec 2014, 20:51
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Real name: James
I tried your suggestion kh99, still nothing displaying even with the null alert.
Reply With Quote
  #4  
Old 04 Dec 2014, 21:07
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
What is the content of the template countrytemplate? And have you turned on the option to view templates in the source code and verified it isn't being called?
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #5  
Old 04 Dec 2014, 21:08
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

But you say you use {vb:raw ccimg}? Notice the extra c.

Edit: nvm you used
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

although I never used that before.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #6  
Old 04 Dec 2014, 21:08
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
OK, maybe try

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

(you can put it right after the existing line so you don't have to delete anything). And see if that shows anything.

Edit: two more good answers snuck in above mine, but I think we're all thinking along the same lines, which is to find out if your template is rendering like you expect.
Reply With Quote
  #7  
Old 04 Dec 2014, 21:31
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Real name: James
It did display "ccimg" after inserting the line kh99 suggested. Also, I am not sure what the content of countrytemplate is. Is it unnecessary to define a new template to add a variable?
Reply With Quote
  #8  
Old 04 Dec 2014, 21:52
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Oh, yeah, if you didn't create a template named 'countrytemplate' then that's the problem. You could do this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


or if you want you could create a template called countrytemplate. Maybe it could contain this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


and then the plugin would be

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


I don't think it matters much, but some people like to keep all html in templates.
Reply With Quote
  #9  
Old 04 Dec 2014, 21:59
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Real name: James
Makes sense. I tried the way you suggested, and it does work. The issue is that country isn't being set. Do I need to do something else to get the field of the person who made the post?
Reply With Quote
  #10  
Old 04 Dec 2014, 22:09
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Oh, yeah, I didn't even think about that. Probably what you should do is use hook location postbit_display_complete, and use $post['field58'] (the $post array has the userinfo of the post's author).

Also what you could do if you wanted, instead of preRegistering to postbit_legacy, is to set $post['ccode'], then just use {vb:raw post.ccode}. I guess that's kind of cheating but as long as nothing else is setting a ccode value then it will work.
Reply With Quote
  #11  
Old 04 Dec 2014, 22:12
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
...but if you still do want to preRegister your own variable, you could use $this->template_prefix . $this->templatename as the template name instead of 'postbit_legacy', so that it will work no matter which postbit template is being used (you could look in file includes/class_postbit.php around line 406 if you want to see why).
Reply With Quote
  #12  
Old 04 Dec 2014, 22:13
KGodel's Avatar
KGodel KGodel is offline
 
Join Date: May 2011
Real name: James
Woo! Thanks everyone, it's working as intended! ^^
Reply With Quote
  #13  
Old 04 Dec 2014, 22:19
nerbert nerbert is offline
 
Join Date: May 2008
I don't think you can use file_get_contents() to read a file you aren't hosting on your own site.

You should make your own file for that


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #14  
Old 04 Dec 2014, 23:00
vBNinja's Avatar
vBNinja vBNinja is offline
 
Join Date: May 2011
I think you should get rid of the file_get_contents and replace it with this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
PM me for Custom Mod Requests/Work
Reply With Quote
  #15  
Old 04 Dec 2014, 23:10
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
...and reverse the keys and values, then you can use isset() to check if the country is there, and you don't need to do a search.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 07:22.

Layout Options | Width: Wide Color: