conditional with tag and category
Posted: 27 February 2008 07:42 PM   [ Ignore ]
Newbie
Rank
Total Posts:  11
Joined  2008-02-27

does anyone know if there’s a way to do something like this:

if there are no entries under ‘sometag’ and ‘somecategory’ then display this,
else display something else

any help is appreciated, thanks!

Profile
 
 
Posted: 28 February 2008 07:09 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3717
Joined  2006-10-18

Have you given the If No Results conditional a whirl? :D

{if no_results}No results to display.{/if} 

 Signature 

Check out the new Solspace Blog!

Profile
 
 
Posted: 16 July 2008 12:16 PM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  21
Joined  2008-05-21

That’s exactly what I’m trying to achieve. Only problem is that the no_results conditional doesn’t work for me. I’m calling the code as an embeded template. The exp:tag:entries is working since outputs the date I want if an entry exists. I just can’t get it to display anything in the event that there’s no entry available.

In case you’re wondering, this code is part of an XML file I’m generating.

{exp:weblog:categories weblog="eintraege" show_empty="no" style="linear" category_group="5" disable="categories|member_data|pagination|trackbacks"}
<url>
<
loc>{site_url}fli/investment/C{embed:currentCategoryID}/tag/{category_name}</loc>
<
lastmod>{exp:tag:entries weblog="eintraege" tag="{category_name}" inclusive="yes" orderby="entry_date" sort="asc" limit="1"}{if no_results}empty{/if}{gmt_edit_date format="{DATE_W3C}"}{/exp:tag:entries}</lastmod>
<
changefreq>weekly</changefreq>
<
priority>0.5</priority>
</
url>
{/exp:weblog:categories} 

Any ideas?

Profile
 
 
Posted: 16 July 2008 12:28 PM   [ Ignore ]   [ # 3 ]
Newbie
Rank
Total Posts:  21
Joined  2008-05-21

Here’s an example of how it looks when it executes the code inside (1) and when it’s not (2).

<url>
<
loc>http://www.example.com/fli/investment/C4/tag/Banken</loc>
(1)<lastmod>2008-05-28T17:30:50+01:00</lastmod>
<
changefreq>weekly</changefreq>
<
priority>0.5</priority>
</
url>
<
url>
<
loc>http://www.example.com/fli/investment/C4/tag/Steuerberatung</loc>
(2)<lastmod></lastmod>
<
changefreq>weekly</changefreq>
<
priority>0.5</priority>
</
url

I’m running EE 1.6.4 build 20080710 and Tag-Module 2.1.1

Profile
 
 
Posted: 16 July 2008 02:15 PM   [ Ignore ]   [ # 4 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3717
Joined  2006-10-18

eexperience,

The {if no_results}{/if} variable pair does work, just that in this case, being wrapped in the weblog:categories loop might be causing a collision

 Signature 

Check out the new Solspace Blog!

Profile