Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Show item on profile page if "x" field is populated
mdb Offline
Junior Member
**
Posts: 27
Joined: May 2012
Post: #11
RE: Show item on profile page if "x" field is populated
(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!
05-23-2012 05:16 AM
Find all posts by this user Quote this message in a reply
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #12
RE: Show item on profile page if "x" field is populated
You guys are the bomb as usual, thanks.
06-07-2012 11:31 PM
Find all posts by this user Quote this message in a reply
nier3 Offline
Member
***
Posts: 125
Joined: Jul 2012
Post: #13
RE: Show item on profile page if "x" field is populated
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

07-27-2012 07:50 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #14
RE: Show item on profile page if "x" field is populated
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.

My Blog
07-27-2012 11:33 PM
Find all posts by this user Quote this message in a reply
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #15
RE: Show item on profile page if "x" field is populated
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?
02-13-2013 06:10 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #16
RE: Show item on profile page if "x" field is populated
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>


02-13-2013 06:37 AM
Find all posts by this user Quote this message in a reply
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #17
RE: Show item on profile page if "x" field is populated
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.
02-13-2013 06:38 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #18
RE: Show item on profile page if "x" field is populated
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.

02-13-2013 06:51 AM
Find all posts by this user Quote this message in a reply
brad-t Offline
Member
***
Posts: 120
Joined: Apr 2011
Post: #19
RE: Show item on profile page if "x" field is populated
It's based on the viewer. Thanks!
02-13-2013 11:07 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: