MyBB Hacks

Full Version: Template Conditionals
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11
I'm guessing we can't use str_replace with arrays for search and replace variables...?
Well, have you tried?
Neither of these worked:

Code:
<func str_replace>array("PlayStation 4", "PlayStation 3", "Xbox One", "Xbox 360"), array("PS4", "PS3", "X1", "360"), $user['fid7']</func>

Code:
<?=str_replace(array("PlayStation 4", "PlayStation 3", "Xbox One", "Xbox 360"), array("PS4", "PS3", "X1", "360"), $user['fid7'])?>


Actually, I can't get any str_replace function to work.
Your first example won't work, because the <func> shortcut only works with single argument functions.
However, your second example works fine for me.

Code:
<?=str_replace(array("PlayStation 4", "PlayStation 3", "Xbox One", "Xbox 360"), array("PS4", "PS3", "X1", "360"), "PlayStation 4")?>

Above prints "PS4"

Strange. I have the above in my memberlist_user template and it outputs nothing. Any ideas?
Install a completely fresh version of MyBB and see if you can reproduce the problem.  If so, post step by step instructions on how to make it fail.
(03-21-2015 09:43 AM)ZiNgA BuRgA Wrote: [ -> ]Install a completely fresh version of MyBB and see if you can reproduce the problem.  If so, post step by step instructions on how to make it fail.
If I have time, I'll try this.

However, I just switched from Template Conditionals to PHP in Templates and Template Conditionals and the <?=str_replace line now works.
You were probably just missing the white-list txt file.
(03-22-2015 05:59 AM)Sama34 Wrote: [ -> ]You were probably just missing the white-list txt file.

Now I feel like an idiot.
hi,

i want to use this code into a template

PHP Code:
$q = $db->simple_select('tablename', 'column');
echo $db->fetch_field($q, 'column'); 


if i use "PHP in Templates / Complex Templates" everything is ok!

if i use "Template Conditionals" nothing is happen.

my question is: is it possible to make this code work for me using "Template Conditionals"?

Pages: 1 2 3 4 5 6 7 8 9 10 11
Reference URL's