The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Why do profile field variables work in some templates but not all?
If I put $post[field2] as the only text/code in the ad_showthread_firstpost template, the value of that field outputs in that location on the page. Basically, it works.
However, if I put that same exact code, $post[field2] , in the ad_header_logo template, I get nothing at all. On the same exact page view, it works in one location but not in the other. Why does this work in ad_showthread_firstpost but not in ad_header_logo ? It also does not work in the ad_navbar_below template as well. Is there something that prevents the use of profile field variables in certain templates? |
#2
|
||||
|
||||
$post is for the postbit. All variables are only available for the templates that within scope.
ad_showthread_firstpost is an ad template, it also happens to be inside of the postbit area, so it should understand to an extent the post var scope. $post is the var that holds all of the data for the postbit of the user who posted. The ad_header_logo template, isn't inside of the postbit, so it doesn't know what user posted a non existent post. Depending on what you want to do, I assume for ad_header_logo you want to show this based off of the user who is already viewing the page? Is that correct? Then user $bbuserinfo $post = postbit* related templates, for the user who actually posted the specific post $thread/$threadinfo = related to the thread, in the showthread and postbit templates $bbuserinfo = user who is currently viewing the site. $vboption = should contain a lot of info, like the admin settings Those are the biggest ones. |
#3
|
|||
|
|||
Zachery, thanks for all those details.
What I'm trying to do is to turn ads off for paid subscribers if they choose to turn them off. For the ads on/off switch I figured I would use a custom radio button profile field in their usercp. My ads are well targeted & highly relevant, so many of my subscribers want to be able to keep them turned on, which is why I don't simply surround ad code with a $bbuserinfo usergroup # conditional. I have the usergroup conditional part of it figured out but am not sure how to take the custom profile field selection & use that as the switch to display or not display the ad code. Thanks in advance for any additional help, I really appreciate it. |
#4
|
||||
|
||||
Why? Unless you want to give them a choice.
for the header, it'd be $bbuserinfo['fieldX'] instead of $post |
#5
|
|||
|
|||
Yes, choice is the reason. Some of my subscribers have mentioned they would like to view the site with ads enabled. That is likely due to the high quality & relevancy of the ads.
Your suggestion worked perfectly. For anyone who comes along looking for the same solution in the future, here's what I ended up using: Code:
<if condition="!is_member_of($bbuserinfo, 12)"> AD CODE GOES HERE <else /> <if condition="(is_member_of($bbuserinfo, 12)) AND (($bbuserinfo[field5] === 'Display All Ads')OR ($bbuserinfo[field5] === ''))"> AD CODE GOES HERE </if> </if> Basically, that displays the the ad to everyone who is not a member of usergroup #12 and then also displays ads to usergroup 12 members if they either have selected to 'Display All Ads' in their profile or if the value of the profile field is empty. I added in the part to display for the empty variable because even though 'Display All Ads' is selected by default, it does not actually save the value for the variable until the user clicks save on the profile page. That's pretty much it. Zachary, thanks for your help! :up: |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|