Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-01-19 00:36:37

dododi
Member
Registered: 2006-01-14
Posts: 17

Hiding related articles, related files etc.

Forgive me if this is an obvious question, but I am trying to figure out how to hide related articles and files for any article that does not currently have any related articles or files assigned to it.

My current template has the following:

[div id=“related_art”]
[h4]Related Articles:[/h4]
[txp:chh_related_articles relation=“keywords” wraptag=“ul” break=“li” section=“contribute_detail” class=“ignore” /]
[p] [/p]
[/div]

[div id=“related_files”]
[h4]Related Files:[/h4]
[txp:file_download_list form=“files_alt1” category=“contribute” sort=“filename” wraptag=“ul” break=“li” class=“ignore”/]
[/div]

I am new to txp and can’t figure out if any of the conditional tags could help. What I would like to do is hide the entire div if a related file or article is not present.

Thanks in advance

p.s. forgive the use of [] instead of <> as I BBCode is off and I am not sure how or if it can be activated

Offline

#2 2006-01-20 10:16:56

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

Re: Hiding related articles, related files etc.

I don’t think there is a way to hide the entire div, but you could try to move the headings to the label attribute. I never tried this myself so I’m not sure it will work. Something like this:
<code>
<txp:chh_related_articles relation=“keywords” label=“Related articles:” labeltag=“h4” wraptag=“ul” break=“li” section=“contribute_detail” class=“ignore” />
</code>
(both tags can take label and labeltag as attributes).

And you can display code on this forum with < code> < /code> tags (without the spaces).

Offline

#3 2006-01-21 07:19:29

takshaka
Archived Plugin Author
From: Below the Manson-Nixon line
Registered: 2004-06-02
Posts: 97
Website

Re: Hiding related articles, related files etc.

Someone else asked about this a while back, and I mentioned I would release a plugin. Eventually — i.e., tonight — I did:

So you should be able to do this:

<code>
<txp:chh_if_data>
<div id=“related_art”>
<h4>Related Articles:</h4>
<txp:chh_related_articles relation=“keywords” wraptag=“ul” break=“li” section=“contribute_detail” class=“ignore” />
<p> </p>
</div>
</txp:chh_if_data>
</code>

Offline

#4 2006-01-22 23:04:43

dododi
Member
Registered: 2006-01-14
Posts: 17

Re: Hiding related articles, related files etc.

Thank you very much to takshaka and doggiez.

I will give the new pluggin a try.

Offline

#5 2006-01-23 03:11:23

dododi
Member
Registered: 2006-01-14
Posts: 17

Re: Hiding related articles, related files etc.

Thanks again Takshaka, your plugin is great.

I love the flexibility of either hiding everything or displaying a paragraph, div etc if empty.

Great work and thanks again.

Offline

Board footer

Powered by FluxBB