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-01-2007, 10:11 AM
mfyvie mfyvie is offline
 
Join Date: Mar 2007
Location: Zurich, Switzerland
Posts: 336
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default problems: str_replace for template edits and conditionals

I'm using str_replace to try and get a plugin to modify a template. This in itself is not a problem, but as soon as I add in a conditional, it doesn't seem to be parsed when the template is run.

Here's what I'm trying to do:
Code:
$disabled_add = ' $disabled /><if condition=\"$disabled==\"disabled\"\"><span style=\"color: grey\">$vbphrase[avatar_taken]</span><else />$avatar[title]</if>';

$vbulletin->templatecache['modifyavatarbit'] = str_replace(' />$avatar[title]', $disabled_add, $vbulletin->templatecache['modifyavatarbit']);
note that I had to use a backslash before the double quotes otherwise all sorts of php errors were being produced.

When we look at the output we see that the conditional statements, instead of being evaluated are finding their way into the HTML output:

HTML Code:
<input type="radio" name="avatarid" value="1880" id="rb_avatarid_1880"   /><if condition="=="disabled""><span style="color: grey">Taken</span><else />Sup29</if> </label>
If I insert the changes directly into the template (without the backslash quoting of course) then the conditionals work as expected.

My guess is that conditionals inserted via str_replace aren't being evaluated correctly. Is this a bug, or does anyone know of any work-arounds. I've tried to find other mods that do this but so far haven't found any. A search of this forum and google has also proved fruitless.

Any help would be appreciated
Reply With Quote
  #2  
Old 06-01-2007, 10:26 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can't base them off conditionals, as they change into ((CONDITION) ? true : false).
Reply With Quote
  #3  
Old 06-01-2007, 10:40 AM
mfyvie mfyvie is offline
 
Join Date: Mar 2007
Location: Zurich, Switzerland
Posts: 336
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
You can't base them off conditionals, as they change into ((CONDITION) ? true : false).
Any ideas for a work-around? Is it possible to maybe include the extra code in a different template, and then simply call that template from inside the template (and make that insertion via str_replace)?

Sorry, kind of muddling my way through this mod, but am learning a lot as I go
Reply With Quote
  #4  
Old 07-05-2007, 08:24 AM
mfyvie mfyvie is offline
 
Join Date: Mar 2007
Location: Zurich, Switzerland
Posts: 336
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
You can't base them off conditionals, as they change into ((CONDITION) ? true : false).
Actually, you can base them off conditionals, you just have to know the correct format, then it is possible.

It's taken me ages, but I figured it all out and wrote it up in a tutorial (or rather series of tutorials) here:

https://vborg.vbsupport.ru/showthread.php?t=151332
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 08:50 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.05259 seconds
  • Memory Usage 2,191KB
  • 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)bbcode_html
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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