The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Template Variable Issue
Hey guys. Before proceeding, I have read https://vborg.vbsupport.ru/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. PHP Code:
PHP Code:
PHP Code:
|
#2
|
|||
|
|||
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:
Code:
if ($ccode != null) { $imgoutput = "<img src='images/flags/$ccode.png' /> "; } else { $imgoutput = "get_ccode('$country') returned null"; } If it's still blank then at least you know that it's something to do with the templates. |
#3
|
||||
|
||||
I tried your suggestion kh99, still nothing displaying even with the null alert.
|
#4
|
||||
|
||||
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?
|
Благодарность от: | ||
KGodel |
#5
|
|||
|
|||
PHP Code:
Edit: nvm you used PHP Code:
|
#6
|
|||
|
|||
OK, maybe try
Code:
$templatevalues['ccimg'] = "ccimg"; 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. |
#7
|
||||
|
||||
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?
|
#8
|
|||
|
|||
Oh, yeah, if you didn't create a template named 'countrytemplate' then that's the problem. You could do this:
PHP Code:
or if you want you could create a template called countrytemplate. Maybe it could contain this: Code:
<img src='images/flags/{vb:raw ccode}.png' /> and then the plugin would be PHP Code:
I don't think it matters much, but some people like to keep all html in templates. |
Благодарность от: | ||
KGodel |
#9
|
||||
|
||||
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?
|
#10
|
|||
|
|||
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. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|