Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-12-2013, 08:24 PM
john2k john2k is offline
 
Join Date: Feb 2002
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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 06-12-2013, 08:35 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$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.
Reply With Quote
  #3  
Old 06-12-2013, 08:54 PM
john2k john2k is offline
 
Join Date: Feb 2002
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 06-12-2013, 09:06 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why? Unless you want to give them a choice.

for the header, it'd be $bbuserinfo['fieldX'] instead of $post
Reply With Quote
  #5  
Old 06-13-2013, 12:10 AM
john2k john2k is offline
 
Join Date: Feb 2002
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
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 10:53 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04322 seconds
  • Memory Usage 2,197KB
  • 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)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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