solved SOLVED - Block only viewable if populated with at least one field?

MAD
MAD
@madc
11 years ago
600 posts
I have added this code to my profile_header.tpl

               
               < div class="block pbpbg" >
< h3 class="pbpfont">BAND MEMBERS< /h3>< br/>
< div class="memspan" >{if strlen($profile_voice) > 2}<span>Voice: </span>{$profile_voice}{/if}<br />
{if strlen($profile_guitar) > 2}<span>Guitar: </span>{$profile_guitar}{/if}<br />
{if strlen($profile_bass) > 2}<span>Bass: </span>{$profile_bass}{/if}<br />
{if strlen($profile_drums) > 2}<span>Drums: </span>{$profile_drums}{/if}<br />
{if strlen($profile_othermembers) > 2}<span>Others: </span>{$profile_othermembers}{/if}<br />
< /div >
                < /div >

How do I only display this block if at least one of the sections has been filled in ie Guitar: ?

I know I'd wrap it in an if statement but anyone have any idea as to what sort?

( I know html is wrong but it kept stripping here in my post )


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion

updated by @madc: 01/21/14 05:01:09AM
Developer Networks
Developer Networks
@developer-networks
11 years ago
566 posts
You could use jrCore_list and create lists and they will populate if they are filled. But the way this is set up would display all people who play drums or guitar. So you would also want to pass a search

so it would look something like this.

 
{jrCore_list module="jrProfile" order_by=$order_by search1="profile_active = 1" search2="profile_quota_id in `$_conf.mySkin_bandmembers_quota`" limit="3" tpl_dir="mySkin" template="myBandmembers_row.tpl"} 

also check out this for the jrCore_List functions to seperate your lists in with more isolation

http://www.jamroom.net/the-jamroom-network/documentation/development/89/jrcore-list


updated by @developer-networks: 12/08/13 06:08:24PM
michael
@michael
11 years ago
7,718 posts
ba9801:...How do I only display this block if at least one of the sections has been filled in ie Guitar: ?

First thing to do is to put {debug} next to the code.

Then refresh the page and the debug panel will open as a popup.

Then locate the variable name your want to check for, it will look something like:

{$something_guitar} or {$_item.something_guitar}

Then only once you know the variable name are you able to use the variable.

{if strlen($something_guitar) > 2}
//do something
{/if}

--edit--
Working on the {debug} docs now, cant believe I forgot such an important function.
They will be here when done:
https://www.jamroom.net/the-jamroom-network/documentation/development/1477/debug
updated by @michael: 12/08/13 08:47:19PM
MAD
MAD
@madc
11 years ago
600 posts
Ok I think I need to add some extra info ( Although the debug tool is great )

I have two quotas at the moment.
members
artists

This block should only show on the Artists Profile NOT the members
So what would i wrap it in to only show this block on the artists quota

eg

{if this profile = artist then display this block If at least one of the fields has info}

< div class="block pbpbg" >
< h3 class="pbpfont">BAND MEMBERS< /h3>< br/>
< div class="memspan" >{if strlen($profile_voice) > 2}<span>Voice: </span>{$profile_voice}{/if}<br />
{if strlen($profile_guitar) > 2}<span>Guitar: </span>{$profile_guitar}{/if}<br />
{if strlen($profile_bass) > 2}<span>Bass: </span>{$profile_bass}{/if}<br />
{if strlen($profile_drums) > 2}<span>Drums: </span>{$profile_drums}{/if}<br />
{if strlen($profile_othermembers) > 2}<span>Others: </span>{$profile_othermembers}{/if}<br />
< /div >
                < /div >

{/if}

Sorry for being dumb here but trying to learn


--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion

updated by @madc: 12/09/13 05:44:00AM
douglas
@douglas
11 years ago
2,791 posts
If it is going in the profile_header.tpl file, and your artist quota ID is 1, then it would look something like this:

{if $profile_quota_id == '1'}

< div class="block pbpbg" >
< h3 class="pbpfont">BAND MEMBERS< /h3>< br/>
< div class="memspan" >{if strlen($profile_voice) > 2}<span>Voice: </span>{$profile_voice}{/if}<br />
{if strlen($profile_guitar) > 2}<span>Guitar: </span>{$profile_guitar}{/if}<br />
{if strlen($profile_bass) > 2}<span>Bass: </span>{$profile_bass}{/if}<br />
{if strlen($profile_drums) > 2}<span>Drums: </span>{$profile_drums}{/if}<br />
{if strlen($profile_othermembers) > 2}<span>Others: </span>{$profile_othermembers}{/if}<br />
< /div >
                < /div >

{/if}

If it is not going in the profile_header.tpl, you'll want to use {debug} for the template your adding it to and make sure the $profile_quota_id is available in that template.

If this variable is not available, then you'll want to use a jrCore_list function on the jrProfile module to get the profiles quota ID.

Hope this helps,
Douglas


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
MAD
MAD
@madc
11 years ago
600 posts
Thanks @douglas!
That worked perfectly.
I renamed the example quota to Artists originally ( id=1 )
Below is my code for anyone else that needs it but it worked great. Love how this system works and the more i"m learning about it the more I love it!

{if $profile_quota_id == '1'}
               <div class="block pbpbg">
<h3 class="pbpfont">BAND MEMBERS</h3><br/>
<div class="memspan">{if strlen($profile_voice) > 2}<span>Voice: </span>{$profile_voice}{/if}<br />
{if strlen($profile_guitar) > 2}<span>Guitar: </span>{$profile_guitar}{/if}<br />
{if strlen($profile_bass) > 2}<span>Bass: </span>{$profile_bass}{/if}<br />
{if strlen($profile_drums) > 2}<span>Drums: </span>{$profile_drums}{/if}<br />
{if strlen($profile_othermembers) > 2}<span>Others: </span>{$profile_othermembers}{/if}<br />
</div>
                </div>
{/if}



--
~ https://punkbandpromotions.com ~
Check us out for all your Punk/Alternative Music!
Check us out on Facebook:- https://facebook.com/PunkBandPromotion

updated by @madc: 12/09/13 07:24:59AM
michael
@michael
11 years ago
7,718 posts
ba9801:Love how this system works and the more i"m learning about it the more I love it!

Put that on twitter and I'd retweet it. ;)

Great to hear.

Tags