Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 12 Jun 2013, 21:24
john2k john2k is offline
 
Join Date: Feb 2002
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?
__________________
...
Reply With Quote
  #2  
Old 12 Jun 2013, 21:35
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
$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.
__________________
Looking for ImpEx?
Reply With Quote
  #3  
Old 12 Jun 2013, 21:54
john2k john2k is offline
 
Join Date: Feb 2002
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.
__________________
...
Reply With Quote
  #4  
Old 12 Jun 2013, 22:06
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
Why? Unless you want to give them a choice.

for the header, it'd be $bbuserinfo['fieldX'] instead of $post
__________________
Looking for ImpEx?
Reply With Quote
  #5  
Old 13 Jun 2013, 01:10
john2k john2k is offline
 
Join Date: Feb 2002
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:


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


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!
__________________
...
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 20:57.

Layout Options | Width: Wide Color: