Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-06-23 15:17:44

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Making an archive page ... how to eleminate an article from a list?

On this page (section) > mariaberkhout.nl/new/info I want to have an archive page (‘archief’). With the help from this tip I’ve got it working > mariaberkhout.nl/new/info/archief … :)

Now the question is: what’s the best way to eleminate the output of the article title ‘Archief’ in the main column and in the menu at the top of the sidebar?

Code main column:

<txp:if_individual_article>
<txp:article class="" wraptag="" form="single_nolink" limit="1" />
<txp:else />
<txp:article class="" wraptag="" break="hr" form="excerpt" sort="position asc" limit="2" />
</txp:if_individual_article>

Code article (‘Archief’)

<txp:article_custom section="info">
<txp:if_first_article><ol class="titles"></txp:if_first_article>
<li><a href="<txp:permlink />" title="<txp:title />"><txp:title /></a></li>
<txp:if_last_article></ol></txp:if_last_article>
</txp:article_custom>

Code sidebar:

<txp:if_individual_article>
<txp:article_custom section="info" sort="position asc" wraptag="ol" class="titles">
<li<txp:if_article_id id='<txp:article limit="1" sort=""><txp:article_id /></txp:article>'> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
<txp:else />
<txp:article_custom section="info" sort="position asc" wraptag="ol" break="li" class="titles" offset="2" excerpted="y"><txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:if_individual_article>

Last edited by RedFox (2014-06-23 15:27:52)

Offline

#2 2014-06-23 16:00:27

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: Making an archive page ... how to eleminate an article from a list?

ol.titles li:first-child { display: none } ?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2014-06-23 20:43:56

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Re: Making an archive page ... how to eleminate an article from a list?

Thanks @uli for joining in. Yes, with CSS it can be done … but I’m ancious if there is a TXP best practice … tag wise I mean.

Offline

#4 2014-06-23 21:16:35

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

Re: Making an archive page ... how to eleminate an article from a list?

Have you tried to make article ‘Archief’ sticky? Not sure if the following code would work:

<txp:if_individual_article>
  <txp:if_article_id id="id-of-article-Archief">
    <txp:article status="sticky" class="" wraptag="" form="single_nolink" limit="1" />
  <txp:else />
    <txp:article class="" wraptag="" form="single_nolink" limit="1" />
  </txp:if_article_id>
<txp:else />
  <txp:article class="" wraptag="" break="hr" form="excerpt" sort="position asc" limit="2" />
</txp:if_individual_article>

Edit: I’m sure I have done this before. Give me a moment to search the forum and my sites…

Last edited by els (2014-06-23 21:17:35)

Offline

#5 2014-06-24 04:31:40

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Re: Making an archive page ... how to eleminate an article from a list?

mariaberkhout.nl/new/info/archief … :)

But … what to do if the article ‘Archief’ is rendered and I want to skip the menu and ‘Archief’ from the sidebar?

Code:

<txp:if_individual_article>
<txp:article_custom section="info" sort="position asc" wraptag="ol" class="titles">
<li<txp:if_article_id id='<txp:article limit="1" sort=""><txp:article_id /></txp:article>'> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
<txp:else />
<txp:article_custom section="info" sort="position asc" wraptag="ol" break="li" class="titles" offset="2" excerpted="y"><txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:if_individual_article>
<hr>
<txp:article_custom section="info" id="59" wraptag="ol" break="li" class="titles"><txp:permlink><txp:title /></txp:permlink></txp:article_custom>
<hr>

I guess it can (also) be done by using <txp:if_article_id id="id-of-article-Archief"> … but I’m getting all kinds of strange effects and/or errors.

Els, one more time please … :)

Last edited by RedFox (2014-06-24 04:32:59)

Offline

#6 2014-06-24 08:25:05

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Re: Making an archive page ... how to eleminate an article from a list?

Ahh … it’s much more simple than I thought … :)

<txp:if_article_id id="85">
<txp:else />
<txp:if_individual_article>
<txp:article_custom section="info" sort="position asc" wraptag="ol" class="titles">
<li<txp:if_article_id id='<txp:article limit="1" sort=""><txp:article_id /></txp:article>'> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article_custom>
<txp:else />
<txp:article_custom section="info" sort="position asc" wraptag="ol" break="li" class="titles" offset="2"><txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:if_individual_article>
</txp:if_article_id>

<txp:if_article_id id="85">
<txp:else />
<hr>
<txp:article_custom section="info" id="85" wraptag="ol" break="li" class="titles"><txp:permlink><txp:title /></txp:permlink></txp:article_custom>
<hr>
</txp:if_article_id>

[edit]
Oops … the individual articles and /archief are ok … the /info isn’t > 2 x “Tag error: <txp:if_article_id id=“85”> -> Textpattern Notice: Article tags cannot be used outside an article context. while parsing form None on page info”

Last edited by RedFox (2014-06-24 08:41:58)

Offline

#7 2014-06-24 14:28:09

etc
Developer
Registered: 2010-11-11
Posts: 5,057
Website GitHub

Re: Making an archive page ... how to eleminate an article from a list?

Joop, try to inverse the if_article_id / if_individual_article nesting. Also, avoid heavy tags like <txp:article /> when possible:

<txp:if_individual_article>
<txp:variable name="currentid" value='<txp:page_url type="id" />' />
<txp:if_variable name="currentid" value="85">
<txp:else />
<txp:article_custom section="info" sort="position asc" wraptag="ol" class="titles">
	<li<txp:if_article_id> class="active"</txp:if_article_id>>
	<txp:permlink><txp:title /></txp:permlink>
	</li>
</txp:article_custom>
<hr />
<txp:article_custom id="85" wraptag="ol" break="li" class="titles">
	<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
<hr />
</txp:if_variable>
<txp:else />
<txp:article_custom section="info" sort="position asc" wraptag="ol" break="li" class="titles" offset="2">
	<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:if_individual_article>

Edit: code simplified.

Last edited by etc (2014-06-24 21:51:10)

Offline

#8 2014-06-24 15:35:22

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Re: Making an archive page ... how to eleminate an article from a list?

Hi, Oleg … thanks for helping me. Your code does the trick … :)

I don’t have dev brains, so is it possible to explain why <txp:if_article_id id="85"> isn’t the same as <txp:variable name="currentid" value='<txp:page_url type="id" />' /><txp:if_variable name="currentid" value="85"> … !?

And why must I avoid heavy tags like <txp:article />? It wasn’t in the last code snippet … or do you refer to some other part of my fantastic homemade source code?

Last edited by RedFox (2014-06-24 15:35:39)

Offline

#9 2014-06-24 17:27:39

etc
Developer
Registered: 2010-11-11
Posts: 5,057
Website GitHub

Re: Making an archive page ... how to eleminate an article from a list?

RedFox wrote #281618:

is it possible to explain why <txp:if_article_id id="85"> isn’t the same as <txp:variable name="currentid" value='<txp:page_url type="id" />' /><txp:if_variable name="currentid" value="85"> … !?

Functionally, there is no difference, but I wasn’t sure <txp:if_article_id /> is always defined at this stage, but you can try.

And why must I avoid heavy tags like <txp:article />? It wasn’t in the last code snippet … or do you refer to some other part of my fantastic homemade source code?

It was in <txp:if_article_id id='<txp:article limit="1" sort=""><txp:article_id /></txp:article>'> inside <txp:article_custom />. This tag requires db querying and some processing, and you call it for each article retrieved by <txp:article_custom />. You only need the current article ID here, so it’s much faster to do it once, store it in <txp:variable /> and call this variable instead of <txp:article />.

Edit: actually, the id attribute of <txp:if_article_id /> defaults to the current id, so it can be omitted there.

Last edited by etc (2014-06-24 21:52:01)

Offline

#10 2014-06-24 20:04:21

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Re: Making an archive page ... how to eleminate an article from a list?

Thanks Oleg … your explanation is very enlightening … :)

Offline

Board footer

Powered by FluxBB