• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Smarty help a better way to do this
PostPosted: Fri Jun 15, 2012 5:39 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 482
Location: Florida
I am using isotope and have an extra field in the news module. It works fine when I hard code the filters. But what if there is no item that matches a filter. I also fixed that too. I did the following ".first" with smarty, it works fine but there must be a shorter/better way:

Code:
{foreach from=$items item=entry name=colorful}
{if $entry->fieldsbyname.filter->value eq 'colorful'}{if $smarty.foreach.colorful.first}
<li><a href="" title="colorful">Colorful</a></li>{/if}
{/if}{/foreach}


Now it works that if there is an entry that has that filter the nav link will show up, if there isn't it won't show up, and it shows up only 1 time. Any better, shorter way to do this? I am smarty illiterate, pretty much...

Thanks!


Top
 Profile  
 
 Post subject: Re: Smarty help a better way to do this
PostPosted: Fri Jun 15, 2012 5:43 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 482
Location: Florida
never mind, this doesn't work.


Top
 Profile  
 
 Post subject: Re: Smarty help a better way to do this
PostPosted: Fri Jun 15, 2012 5:52 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 6609
Location: Fernie British Columbia, Canada
Code:
{assign var='tmp' value=0}
{foreach from=$items item=entry name=colorful}
  {if $entry->fieldsbyname.filter->value eq 'colorful' and $tmp == 0}
  <li><a href="" title="colorful">Colorful</a></li>
  {assign var='tmp' value=1}
{/if}
{/foreach}

_________________
Follow me on twitter
--
if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: Smarty help a better way to do this
PostPosted: Fri Jun 15, 2012 6:01 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 482
Location: Florida
Dude you rock! Thank you!!!!!

Code:

{assign var='colorful' value=0}
{foreach from=$items item=entry name=colorful}
  {if $entry->fieldsbyname.filter->value eq 'colorful' and $colorful == 0}
  <li><a href="" title="colorful">Colorful</a></li>
  {assign var='colorful' value=1}
{/if}
{/foreach}

{assign var='clean' value=0}
{foreach from=$items item=entry name=clean}
  {if $entry->fieldsbyname.filter->value eq 'clean' and $clean == 0}
  <li><a href="" title="clean">Clean</a></li>
  {assign var='clean' value=1}
{/if}
{/foreach}




Top
 Profile  
 
 Post subject: Re: Smarty help a better way to do this
PostPosted: Fri Jun 15, 2012 6:17 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Feb 08, 2007 6:11 pm
Posts: 482
Location: Florida
I realized that some entries have more than one filter so this worked:

{assign var='colorful' value=0}
{foreach from=$items item=entry name=colorful}
{if $entry->fieldsbyname.filter->value|strstr:'colorful' and $colorful == 0}
<li><a href="" title="colorful">Colorful</a></li>
{assign var='colorful' value=1}
{/if}
{/foreach}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner