Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-10-25 14:33:57

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

need help with categories and article landing page.

Hi I should know how to do this but I don’t use categories much so I’m wondering what the best way to go about it is.

I have a blog section that has 4 different categories on it.
There are article excerpts from these categories on various pages of the site.
If a permalink from an article is clicked I I want the blog section “landing” page to display a list of articles from the specific category that the article belonged to with a list of other articles from that category below it. If the section link is clicked I just want it to display the most recent article from any of the categories followed by headings and category lists like this:

<txp:if_category>
     <txp:article_custom category="<txp:category />" form="single"  section="blog" />
     <txp:article_custom category="<txp:category />" form="list"  section="blog" />
</txp:if_category>
 <txp:else />
  <txp:if_individual_article>
	<txp:article form="single"  />
</txp:if_individual_article>
<txp:else />
<txp:article_custom category="upcoming-events" form="article_listing"   section="blog" />
<txp:article_custom category="special-offers" form="article_listing"   section="blog" />
<txp:article_custom category="tips" form="article_listing"  section="blog" />
</txp:if_individual_article>

well something like that but that actually works.

Last edited by kvnmcwebn (2011-10-25 14:34:34)


its a bad hen that wont scratch itself.
photogallery

Offline

#2 2011-10-25 14:43:22

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

Re: need help with categories and article landing page.

A bit of jiggery pokery with your single and double quotes, as well as improving the txp:else flow should help. Something like this maybe? (untested) :

<txp:if_category>
    <txp:article_custom category='<txp:category />' form="single" section="blog" />
    <txp:article_custom category='<txp:category />' form="list" section="blog" />
 <txp:else />
    <txp:if_individual_article>
        <txp:article form="single"  />
    <txp:else />
          <txp:article_custom category="upcoming-events" form="article_listing" section="blog" />
          <txp:article_custom category="special-offers" form="article_listing" section="blog" />
          <txp:article_custom category="tips" form="article_listing" section="blog" />
    </txp:if_individual_article>
</txp:if_category>

You can probably be even more clever than that (e.g. the category attribute accepts a list of categories) but I’ll leave that to the tag geniuses to advise. For now that should get you moving.


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

Online

#3 2011-10-25 15:01:22

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: need help with categories and article landing page.

ahh i forgot about the quotes within tags. I’ll give it a go now. Thanks steph!


its a bad hen that wont scratch itself.
photogallery

Offline

#4 2011-10-25 15:11:54

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: need help with categories and article landing page.

steph a permlink from a different section is not going to the blog section but instead just goes to the “articles” section which I’m not even using. This is from an excerpted category from the blog section on the home page. Is there something i can do to make the permlink go to the blog section/category?


its a bad hen that wont scratch itself.
photogallery

Offline

#5 2011-10-26 17:38:21

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: need help with categories and article landing page.

woah that was my fault. everything working now. thanks


its a bad hen that wont scratch itself.
photogallery

Offline

#6 2011-10-26 18:03:59

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: need help with categories and article landing page.

ahh still not working.

<txp:if_category>
    <txp:article_custom category='<txp:category />' form="single" section="picture-framers-blog-art-events-in-letterkenny-co-donegal" />
    <txp:article_custom category='<txp:category />' form="list" display="9"  />
 <txp:else />
    <txp:if_individual_article>
        <txp:article form="single"  />
    <txp:else />
          <txp:article_custom category="upcoming-events" form="article_listing" section="picture-framers-blog-art-events-in-letterkenny-co-donegal" />
          <txp:article_custom category="special-offers" form="article_listing" section="picture-framers-blog-art-events-in-letterkenny-co-donegal" />
          <txp:article_custom category="tips" form="article_listing" section="picture-framers-blog-art-events-in-letterkenny-co-donegal" />
    </txp:if_individual_article>
</txp:if_category>

this line:

<txp:article_custom category='<txp:category />' form="list" display="9"  />

seems to be getting ignored.

Last edited by kvnmcwebn (2011-10-26 18:04:47)


its a bad hen that wont scratch itself.
photogallery

Offline

#7 2011-10-26 19:13:29

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

Re: need help with categories and article landing page.

display="9"? You could try limit="9" ;)

Offline

#8 2011-10-26 20:14:10

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: need help with categories and article landing page.

ha ha. oops.
still not the problem though. What are the other reasons why the list of articles should not display underneath the article arrived at by permlink?


its a bad hen that wont scratch itself.
photogallery

Offline

#9 2011-10-26 20:16:27

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: need help with categories and article landing page.


its a bad hen that wont scratch itself.
photogallery

Offline

#10 2011-10-26 20:46:12

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: need help with categories and article landing page.

Still don’t understand so I’m just going to make the archived events category a section.


its a bad hen that wont scratch itself.
photogallery

Offline

#11 2011-10-26 20:51:07

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

Re: need help with categories and article landing page.

Can you post a tag trace?

Offline

#12 2011-10-26 21:10:14

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: need help with categories and article landing page.

interesting…

trace:

<txp:if_category>
	[<txp:if_category>: false]
	<txp:if_individual_article>
		[<txp:if_individual_article>: true]
		<txp:article form="single"  />
			[SQL (0.00045514106750488): select Form from txp_form where name='single']
			[Form: single]
			<txp:title />
			<txp:body />
	</txp:if_individual_article>
</txp:if_category>

txp:

<txp:if_category>
    <txp:article_custom category='<txp:category />' form="single" section="picture-framers-blog-art-events-in-letterkenny-co-donegal" />
    <txp:article_custom category='<txp:category />' limit="9" form="list"  />
 <txp:else />
    <txp:if_individual_article>
        <txp:article form="single"  />
    <txp:else />
          <txp:article_custom category="upcoming-events" form="article_listing" section="picture-framers-blog-art-events-in-letterkenny-co-donegal" />
          <txp:article_custom category="special-offers" form="article_listing" section="picture-framers-blog-art-events-in-letterkenny-co-donegal" />
          <txp:article_custom category="tips" form="article_listing" section="picture-framers-blog-art-events-in-letterkenny-co-donegal" />
    </txp:if_individual_article>
</txp:if_category>

Last edited by kvnmcwebn (2011-10-26 21:10:36)


its a bad hen that wont scratch itself.
photogallery

Offline

Board footer

Powered by FluxBB