(05-23-2012 05:01 AM)RateU Wrote: [ -> ]maybe you can write it like this:
Code:
<if preg_match('~^STEAM_\d:\d:\d{8}$~',$userfields['fid4']) then>
<func htmlspecialchars_uni>{$userfields['fid4']}</func>
</if>
|
Or, if you're really sure about the output value, you can remove the htmlspsecialchars_uni for that.
Modify the pattern as your needs.
Thanks so much RateU, that worked perfectly!
You guys are the bomb as usual, thanks.
Hi, can I use this code:
Code:
<if preg_match('~^STEAM_\d:\d:\d{8}$~',$userfields['fid4']) then>
<func htmlspecialchars_uni>{$userfields['fid4']}</func>
</if>
|
for "Location"?
I would like to show on postbit_classic: Location: $post['fid1'] only if 'fid1' (Location) is populated.
Thanks
You'll need PHP in Templates at least as preg_match is not an allowed function in Template Conditionals.
Alternatively, if you want to use Template Conditionals, you can whitelist the preg_match function in the inc/phptpl_funcs.php list.
Something a bit different but still related.
I want to hide a control in "Pro" mode, which can be enabled via a radio button. So:
Enable Pro Mode?
-- Yes
-- No
Then, I want to add a class in the case that Pro Mode is enabled, so something like ...
<if $fid8 == yes then>pro_class</if>
Aha, forgive me juvenile example ... but can this be done?
If the radio button comes from a custom profile field, and the additional "class" should be added on profile page, maybe you can do that like this (example):
HTML Code
<div class="normal<if $userfields['fid8'] == 'Yes' then> pro_class</if>">
Contents here
</div>
|
No, it wouldn't be on the profile page, sorry. I should have specified. That would've made it much easier, haha. It would be in multiple places on the site.
Based on the viewer? You can use $mybb->user['fid8'] globally.
But if it is based on the data owner, it depends on in which section/page.
It's based on the viewer. Thanks!