solved Conditionally Hide Block on Profile

gary.moncrieff
gary.moncrieff
@garymoncrieff
10 years ago
865 posts
Hey Guys

I have blocks on my profile index pages which I want to hide if the jrcore_list function returns 0 results.

ie

		        <div class="head_2" style="margin-top:5px;">WE'RE HIRING</div>
		        <div class="block mb20" style="border:1px solid #DEDEDE;">
		            <div class="block_content">
		                <div class="item2">
		
			            {jrCore_list module="gmJobs" profile_id=$_profile_id order_by="_created numerical_desc" limit="3"}
		
		                </div>
		            </div>
		        </div>

What's the easiest way to achieve this? I feel I am overlooking something very obvious lol

updated by @garymoncrieff: 04/03/15 08:43:57PM
paul
@paul
10 years ago
4,335 posts
{jrCore_list module="gmJobs" profile_id=$_profile_id order_by="_created numerical_desc" limit="3" assign="jobs"}
{if strlen($jobs) > 0}
    {$jobs}
{/if}
hth


--
Paul Asher - JR Developer and System Import Specialist
gary.moncrieff
gary.moncrieff
@garymoncrieff
10 years ago
865 posts
That wont hide the block and heading though I aa thinking but I will it, thanks.
paul
@paul
10 years ago
4,335 posts
Yeah - Put the jrCore_list call first, then all of the block code inside the if statement.


--
Paul Asher - JR Developer and System Import Specialist
gary.moncrieff
gary.moncrieff
@garymoncrieff
10 years ago
865 posts
I tried that too and it doesn't seem to work.
douglas
@douglas
10 years ago
2,804 posts
This should be what your looking for...

{jrCore_list module="gmJobs" profile_id=$_profile_id order_by="_created numerical_desc" limit="3" assign="jobs"}
{if strlen($jobs) > 0}
<div class="head_2" style="margin-top:5px;">WE'RE HIRING</div>
<div class="block mb20" style="border:1px solid #DEDEDE;">
	<div class="block_content">
	    <div class="item2">
	    	{$jobs}
	    </div>
	</div>
</div>
{/if}

provided the gmJobs module has all the correct templates.


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
gary.moncrieff
gary.moncrieff
@garymoncrieff
10 years ago
865 posts
It is a basic module created with Aparna so I am not sure not could be missing but no combination of this code will work.

I'm not having a good day started off with me deleting my skin while trying to clean up a bit lol luckily I had a copy of the site stored locally in PhpStorm.
douglas
@douglas
10 years ago
2,804 posts
When you say it is not working, it it not showing anything or are you getting error messages?


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
gary.moncrieff
gary.moncrieff
@garymoncrieff
10 years ago
865 posts
It shows when there is a job listing and even when there isnt.
douglas
@douglas
10 years ago
2,804 posts
Give this a try:

{jrCore_list module="gmJobs" profile_id=$_profile_id order_by="_created numerical_desc" limit="3" assign="jobs"}
{if isset($jobs) && strlen($jobs) > 0}
<div class="head_2" style="margin-top:5px;">WE'RE HIRING</div>
<div class="block mb20" style="border:1px solid #DEDEDE;">
	<div class="block_content">
	    <div class="item2">
	    	{$jobs}
	    </div>
	</div>
</div>
{/if}



--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
michael
@michael
10 years ago
7,800 posts
gary.moncrieff:It shows when there is a job listing and even when there isnt.

Next thing to do is to put a {debug} in after that call and see what is in $jobs.

Once you know what is coming back you can style a conditional statement to check.
gary.moncrieff
gary.moncrieff
@garymoncrieff
10 years ago
865 posts
After a good nights sleep, first in a long time I got it, I finally got it.

{if profile_gmJobs_item_count > 0}
.....
{/if}

Thanks guys, been away from Jamroom dev for too long lol
michael
@michael
10 years ago
7,800 posts
Nice one :)

Tags