Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-20-2010, 09:57 PM
iDCamps iDCamps is offline
 
Join Date: Oct 2009
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Use Profile Field Values in Templates

I'm trying to use a custom profile field (specifically, field5) in various places throughout templates. In some places it works just fine (for example, in memberaction_dropdown when it is referenced by postbit). However, other times it doesn't work because the information wasn't passed along to it (for example, in memberaction_dropdown when it is reference by forumbit).

What is the least intrusive way I can get this information passed to the various places I need?

Thanks.
Reply With Quote
  #2  
Old 12-20-2010, 10:56 PM
ry215 ry215 is offline
 
Join Date: Apr 2006
Location: Paraguay
Posts: 508
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

in template postbit (or postbit_legacy) it called
HTML Code:
{vb:raw $post.fieldX}
but in another templates it called
HTML Code:
{vb:raw $bbuserinfo.fieldX}
Reply With Quote
  #3  
Old 12-21-2010, 03:25 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It actually depends on if you are trying to get the field of the viewer ($bbuserinfo) or the person who's post/profile/whatever you are viewing ($post, $userinfo, $prepared, etc).
Reply With Quote
  #4  
Old 01-04-2011, 02:06 PM
iDCamps iDCamps is offline
 
Join Date: Oct 2009
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, that's what I thought.

And that's also the problem: I want to use the value for the person that did the posting in most cases. I also want it to update itself if the person changes that value.

Thus it seems like it isn't available in most places by default. Is there any way that I can drop the in? Could I do it with some form of plugin?

--------------- Added [DATE]1294162617[/DATE] at [TIME]1294162617[/TIME] ---------------

Okay, so I've made a bit of progress.

I've figured out I can make a plugin which will preRegister the values I need. I can then go in to each template and make it use the value.

Now, the tricky part which I could use some guidance on. Obviously each thing needs a different variable converted. Is there any way to get that variable out of the template into my plugin?

For example, forumhome_forumbit_level2_post has a variable forum.lastpostinfo which contains the username. I'd like to get this variable and then either replace it by preRegistering another variable, or even better, just replacing the value in this variable.

I tried creating a new template for this (using vB_Template::create), but it had no registered variables.

Is there a way to do this? The alternative would be to figure out the query for each thing and put in the proper data, but that would be quite a hassle.

Thanks.
Reply With Quote
  #5  
Old 01-04-2011, 04:57 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm sorry, but you have totally lost me as far as what you need help with right now.

If you create a new template, then you can register variables in it just before you render it:
PHP Code:
$newTemplate vB_Template::create('someTemplate');
    
$newTemplate->register('variable1'$somearray);
    
$newTemplate->register('variable2'$variabletwo);
$newTemplate->render(); 
Reply With Quote
  #6  
Old 01-04-2011, 05:06 PM
iDCamps iDCamps is offline
 
Join Date: Oct 2009
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I know that much, thanks though.

Let me try to rephrase.

Basically what I want to do is go through and anywhere that a username is shown (in last posts, in post headers, etc), I want to replace that value with a profile field.

I've accomplished this in one place, in memberaction_dropdown. However, it only takes affect when viewing an actual thread, because apparently that's the only place that the field variables are caught (elsewhere it uses the username still because I have it show that using a conditional that checks if the field is set).

So, what I -think- is my problem is I need a way of injecting variables into the various templates I need.

That much I can accomplish using a plugin which is currently hooked to global_start which preRegisters the values I need for each template. I can then go into each template and put those variables into use.

The tricky part is obviously I need to do these changes based on some other value. For example, in some places I'll need to determine what the current value is. This is where I'm stuck... how can I figure out what that value would be.

I know PHP forwards and backwards, but I'm still confused how vB passes variables around between the various template bits, and more importantly, how I can intercept those.

Any help you can provide would be greatly appreciated. If I'm approaching this from the wrong angle, please let me know. The only requirement I'm trying to maintain for this goal is to not have to edit any core code.

Thanks.
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 01:40 AM.


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