Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-08-24 16:35:41

Bellezza
New Member
Registered: 2009-06-08
Posts: 5

Using <hr> in sidebar - IF code

I’m new at using textpattern and still learning HTML but I was wondering if I could write some form of an IF statement for an <hr> to show up after a section in a sidebar. For example:

<txp:if_category name="media-concentration"><!-- Information specific to Media Concentration-->
<txp:if_individual_article>	
        <txp:recent_articles section="issues" category="media-concentration" label="Resources" labeltag="h5"  break="h3" sort="id asc" />
</txp:if_individual_article>
<hr noshade>
	<txp:category_list parent="media-concentration" exclude="media-concentration" label="Featured Issues" labeltag="h5" break="h3" />
<hr noshade>

If I have the <hr noshade> after each section, it will show up, but if there aren’t any articles or parts for that section, there are two <hr>s in a row and I don’t like that, obviously.

Any ideas?

Is there something better than this out there?

Thanks.

(Edited for better code display. -Els)

Last edited by els (2009-08-24 21:02:14)

Offline

#2 2009-08-24 21:19:14

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Using <hr> in sidebar - IF code

You can use <txp:variable /> and <txp:if_variable> to check for content, for example:

<txp:category_list parent="media-concentration" exclude="media-concentration" label="Featured Issues" labeltag="h5" break="h3" />
<txp:variable name="category_content" value='<txp:category_list parent="media-concentration" exclude="media-concentration" />' />
<txp:if_variable name="category_content" value="">
	<!-- no content, no hr -->
<txp:else />
	<hr />
</txp:if_variable>

Just repeat the tag you used to display your content (could also be an article tag, related_articles, whatever) in the value attribute of the <txp:variable /> tag.

Btw <hr noshade> is invalid xhtml, so it would be better to use something like <hr class="noshade" /> and style .noshade in your CSS.

Offline

Board footer

Powered by FluxBB