Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-07-03 10:08:00

gavnosis
Member
From: Milton Keynes, UK
Registered: 2005-03-12
Posts: 151
Website

if category list? Lost in conditional logic!

I’m using the built in txp:category_list tag, to display a list of articles in a section grouped by category, as a sort-of sub navigation: (news) articles are grouped by date, and can also be sorted by category. So far, so good.

<ul> <txp:category_list break="li" section="news" /> </ul>

However I’ve now got three scenarios I want to be able to display:

1. The news section, including a preamble of how it works, displaying the most recent articles
2. An individual article
3. A list of articles grouped by category, without the preamble

My news page has this much so far

<txp:if_article_list>
<txp:output_form form="_news_introduction" />
<txp:article form="_news" limit="5" />
</txp:if_article_list>

<txp:if_individual_article>
<txp:article form="_news" limit="10" />
<p>
<txp:link_to_prev> &laquo; <txp:prev_title /></txp:link_to_prev>
<txp:link_to_next><txp:next_title /> &raquo; </txp:link_to_next>
</p>
</txp:if_individual_article>

How can I manage a third case? i.e. an article list, but grouped by category?
Once again, any help would be greatly appreciated!

Thank you, Gavnosis

Offline

#2 2008-07-03 12:02:58

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

Re: if category list? Lost in conditional logic!

I’m confused, category list doesn’t give a list of articles but of categories, right? Or did you mean something I missed?

<txp:article_custom category="your_category" /> could be what you’re looking for (optionally restricted to a certain section), but you leave open how you intend your page to work, so no clue where to place it, under which condition(s)/conditionals.

[BTW, an article tag put between if_individual_article tags can’t make use of limit="5", it’s always a single one.]


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

Offline

#3 2008-07-03 12:18:11

gavnosis
Member
From: Milton Keynes, UK
Registered: 2005-03-12
Posts: 151
Website

Re: if category list? Lost in conditional logic!

Thanks Uli.

Perhaps my examples below will show what I’m trying to do:

1. The news section, with a list of the 5 most recent articles

2. Articles displayed by similar category, newsletter

3. An individual article

…And I got rid of the limit=“10” (Thanks!)

Basically, I want to get rid of the bit about RSS when displaying a list of articles. Is this possible?

Gavnosis

Last edited by gavnosis (2008-07-03 12:18:31)

Offline

#4 2008-07-03 13:33:58

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

Re: if category list? Lost in conditional logic!

Sorry, I don’t get it. You want to get rid of the RSS feed link on pages displaying lists of articles? (This is what I understand, but seems a bit illogical.)


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

Offline

#5 2008-07-03 14:24:11

gavnosis
Member
From: Milton Keynes, UK
Registered: 2005-03-12
Posts: 151
Website

Re: if category list? Lost in conditional logic!

Guten Tag!

Well not get rid of the RSS feed per se, it’s just I have a little bit which reads

Comments made on articles are moderated, and must be approved before they are published.

Not a big thing (yet!), but I’d just like to be able to differentiate between my default list of articles (sorted by date) and my list of articles sorted by category… or can I specify a different page to use? Or a form to only use in one instance?

Offline

#6 2008-07-03 14:36:09

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

Re: if category list? Lost in conditional logic!

_In order to let the quoted sentence appear on individual articles’ pages instead of list pages as is right now, surround it with if_individual_article tags. If not, ask back again.-

Edit: Sorry, seems I get there, slow but get there. Which filtering critera/tag attributes have you used around/for your article tag on the page where you want to display the sentence?

Last edited by uli (2008-07-03 14:50:06)


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

Offline

#7 2008-07-03 14:36:57

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 976
Website

Re: if category list? Lost in conditional logic!

If that is your goal, and if I understand what you want to do, can’t you move just the “comments are moderated” portion of your code into the if_individual_article ?

Offline

#8 2008-07-03 14:37:31

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 976
Website

Re: if category list? Lost in conditional logic!

Sorry uli – you posted while I was typing! :)

Offline

#9 2008-07-04 09:09:05

gavnosis
Member
From: Milton Keynes, UK
Registered: 2005-03-12
Posts: 151
Website

Re: if category list? Lost in conditional logic!

Thank you Uli and Maverick for your time and help so far…

Before I go any further, am I correct in assuming that if I’m using txp:category_list to generate a list of categories in a particular section, then there’s no way I choose which page is used to display the list of articles displayed for each category?

(I want the ‘comments are moderated’ bit to appear in the list of articles grouped by date, but not the list of articles grouped by category)

1. To recap, I want my news section to display excerpts of the 5 most recent articles, using page news.This is therefore an if_article_list. It also contains a little bit of stuff about news in general, from the form ‘_news_introduction’
2. I want an individual article to be displayed in full, also using the news page; this is therefore if_individual_article
3. I have a third case: when I click on one of the category headings, I want to see a list of articles (sorted by category now, not date), and I don’t want to see my _news_introduction. So it’s if_article_list but not the same as the first one.

Does that make sense?

Thanks,

Gavnosis

All of these pages also have a list of categories (in the news section) visible, generated using this:

<ul>
<txp:category_list break="li" section="news" />
</ul>

My first bit

<txp:if_article_list>
<txp:output_form form="_news_introduction" />
<txp:article form="_news" limit="5" />
</txp:if_article_list>

form=”_news_introduction” :

<h3>Recent News and Activities at Sharon Leighton Consultancy</h3>
<div id="preamble">
<p><strong>Comments</strong> made on articles are <strong>moderated</strong>,
and must be approved before they are published.</p>
<p><img src="<txp:site_url />images/10.gif" width="16" height="16"
alt="RSS News Feed" title="" /> Subscribe to the
<txp:feed_link label="RSS News Feed" /></p>
</div>

form=”_news”

<txp:if_individual_article>
<h3><txp:title /></h3>
<txp:body />
<txp:comments_invite wraptag="p" />
<div class="divider"><img src="<txp:site_url />images/1.gif"
width="400" height="1" alt="---" title="" /></div>
<txp:else />
<h3 class="news"><txp:title /></h3>
<txp:excerpt />
<p><a href="<txp:permlink />" title="<txp:title />">Read more</a>... </p>
<div class="divider"><img src="<txp:site_url />images/1.gif"
width="400" height="1" alt="---" title="" />
</div>
<txp:if_individual_article>

Offline

#10 2008-07-04 09:25:51

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,451
Website GitHub

Re: if category list? Lost in conditional logic!

gavnosis wrote:

when I click on one of the category headings, I want to see a list of articles (sorted by category now, not date), and I don’t want to see my _news_introduction. So it’s if_article_list but not the same as the first one.

Isn’t this what <txp:if_category /> is for in the same page as your other stuff? e.g. in your news page:

<txp:if_category>

//  Category has been clicked, show category title and a list of articles in that category
<h2>Articles in <txp:category /></h2>
<txp:article form="excerpts" /> // Context sensitive - it "knows" you're in a category

<txp:else />

  <txp:if_article_list>
    // Show list
  </txp:if_article_list>

  <txp:if_individual_article>
    // Show individual article
  </txp:if_individual_article>

</txp:if_category>

Or have I misunderstood?

Last edited by Bloke (2008-07-04 09:26:24)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#11 2008-07-04 09:58:58

gavnosis
Member
From: Milton Keynes, UK
Registered: 2005-03-12
Posts: 151
Website

Re: if category list? Lost in conditional logic!

Nope! You’ve understood perfectly: that’s exactly what I was after

1. My news section
2. My news articles grouped by Newsletter (for example)
3. An individual article

This is my code, pretty much as you suggested

<txp:if_category>
<h4>Articles in <txp:category /></h4>
<txp:article form="_news_excerpt" />
<txp:else />
<txp:if_article_list>
<txp:output_form form="_news_introduction" />
<txp:article form="_news_excerpt" limit="5" />
</txp:if_article_list>
<txp:if_individual_article>
<txp:article form="_news_detail" />
<p>
<txp:link_to_prev> &laquo; <txp:prev_title /></txp:link_to_prev>
<txp:link_to_next><txp:next_title /> &raquo; </txp:link_to_next>
</p>
</txp:if_individual_article>
</txp:if_category>

So THANK YOU (a big thankyou, see!)

What’s worrying is that I failed totally to find txp:if_category because I was looking for txp:if_category_list. Oh well…

Gavnosis

BTW any idea why my site has the category name has a scruffy URL like this ?c=Newsletter

Offline

#12 2008-07-04 10:10:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,451
Website GitHub

Re: if category list? Lost in conditional logic!

gavnosis wrote:

that’s exactly what I was after

Excellent. Glad you got it sorted.

BTW any idea why my site has the category name has a scruffy URL like this ?c=Newsletter

Pass, sorry.

Looks like you’re set to use clean URLs (otherwise I think you’d see ?s=section_name) so that’s a bit of a mystery to me. The category tag is supposed to read which style of links you have and offer /category/name_of_cat instead of ugly messy URLs. Hmmm. If it’s any consolation I’ve had this happen to a site of mine and I never figured what triggered it. Must be something simple. Somewhere!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB