Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-01-20 21:43:36

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

display categories beloning to a section

Hello all,

I would like to create a sub navigation based on the section which is chosen. I was thinking to do this with categories. So i created a Category named: Articles which has a few childeren (Earring, bracelets etc).
What i would like to produce is that when the the user clicked on the section “Articles” in the left bar the categories “Earrings” and “Bracelets” are displayed.

I hope somebody can tell me if this is possible?

Thanks in advance.

Kind regards,

Maarten.


Kind regards,

Maarten

Offline

#2 2009-01-20 21:51:50

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

Re: display categories beloning to a section

Hello Maarten,

I’ve used a plugin from Christophe Beyls to do this cbs_category_list …although there might well be a more elegant way to achieve this.

Basically, it creates a section-specific list of categories, which I think is what you’re after.

G.

Offline

#3 2009-01-20 21:54:39

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

Re: display categories beloning to a section

Hello Gavnosis,

Thanks for the quick reply. I will take a look at the plugin. I hope somebody can tell my if this can be achieved without a plugin.

Kind regards,

Maarten.


Kind regards,

Maarten

Offline

#4 2009-01-23 21:15:01

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

Re: display categories beloning to a section

Hi all,

Can somebody explain me how the attribute “this_section” of <txp:category_list> works?

I created the following categories:

1. Parent
1.1. Child1
1.2. Child2
1.3. Child3

What i would like to achieve is that when somebody clicks on a section, only the childeren of the parent category belonging to the section are displayed. I hope somebody can tell me if this is possible without a plugin and if it’s possible how to achieve it.

Hope to hear soon.

Last edited by maartenD (2009-01-23 21:16:01)


Kind regards,

Maarten

Offline

#5 2009-01-24 00:31:07

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

Re: display categories beloning to a section

this_section="1" will open the category list on the current section page, so if your category_list tag is on section page /articles/, the links will be like /articles/?c=category-name.

What i would like to achieve is that when somebody clicks on a section, only the childeren of the parent category belonging to the section are displayed.

Not sure if I understand you correctly, but if you mean that every section page should display it’s own category menu, based on the parent category, you could do this: name the parent category exactly like the section, for example ‘articles’, and create the child categories for it that should be displayed in section ‘articles’. Then use category_list like this:

<txp:category_list parent='<txp:section />' exclude='<txp:section />' this_section="1" />

On a section page this will display a list of child categories that belong to the parent category with the same name as the current section.

Offline

#6 2009-01-25 12:32:11

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

Re: display categories beloning to a section

@els,

thx Els, your hint works perfect!!! The problem i now have is, how to show only the articles belonging to a specific category.

Any idea?

Thx in advance.

Last edited by maartenD (2009-01-25 12:32:25)


Kind regards,

Maarten

Offline

#7 2009-01-25 17:19:36

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

Re: display categories beloning to a section

maartenD wrote:

The problem i now have is, how to show only the articles belonging to a specific category.

? Unless I misunderstand you, the <txp:article /> tag will do that for you… Because it is context sensitive it will only display articles from the category/section currently being viewed. So on page /articles/?c=yourcategory, only articles from section ‘articles’ and category ‘yourcategory’ will be displayed.

Offline

#8 2009-01-25 17:28:45

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

Re: display categories beloning to a section

Els wrote:

The problem i now have is, how to show only the articles belonging to a specific category.
? Unless I misunderstand you, the <txp:article /> tag will do that for you… Because it is context sensitive it will only display articles from the category/section currently being viewed. So on page /articles/?c=yourcategory, only articles from section ‘articles’ and category ‘yourcategory’ will be displayed.

That’s correct, what i mean is that when i display the Section i also see articles which are posted in that section, but have a category of one of the child’s. What i want to achieve is, when i click in the main nav bar on a link (which is a section) that only the articles which belongs to that section/category are shown. And when i click on a link in the detailnav only the articles which belongs to the section/child category are shown (this is already working).

I hope you understand what i mean.

thx again in advance for all your helpfull answers.


Kind regards,

Maarten

Offline

#9 2009-01-25 20:15:08

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

Re: display categories beloning to a section

maartenD wrote:

when i display the Section i also see articles which are posted in that section, but have a category of one of the child’s. What i want to achieve is, when i click in the main nav bar on a link (which is a section) that only the articles which belongs to that section/category are shown.

Sorry, I’m still not sure I get it… Do you mean that on the section page (/articles/) you only want to display articles from that section, that don’t have a category assigned? Or articles that are in category ‘articles’, but not in one of the child categories? And in the latter case, do you assign just one category to your articles (either the parent or a child category), or two (both the parent and the child category)?

Offline

#10 2009-01-25 20:24:08

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

Re: display categories beloning to a section

@Els

Below is what i try to achieve:

Articles that are in category ‘articles’, but not in one of the child categories?

Els wrote:

And in the latter case, do you assign just one category to your articles (either the parent or a child category), or two (both the parent and the child category)?

I assign just one category (either the parent or a child category).

Thx again.


Kind regards,

Maarten

Offline

#11 2009-01-25 20:48:18

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

Re: display categories beloning to a section

maartenD wrote:

I assign just one category (either the parent or a child category).

Good, that makes it easier :)

<txp:if_section><!-- you can add name="section1,section2,etc" if it only goes for certain sections -->

<txp:if_category name=""><!-- if we are not on a category page -->
	<txp:article_custom category='<txp:section />' />
<txp:else />
	<txp:article />
</txp:if_category>

<txp:else />
<!-- here your tag(s) for front page, search etc. -->
</txp:if_section>

If your sections use their own page templates, you can of course drop the if_section tags.

Beware! This example assumes you are using 4.0.8, which is when the behaviour of <txp:if_category name=""> changed. Now it means: ‘if we are not on a category page’; it used to mean ‘if we are on a (any) category page’.

Offline

#12 2009-01-26 20:38:30

maartenD
Member
From: Warnsveld, The Netherlands
Registered: 2007-12-08
Posts: 47
Website

Re: display categories beloning to a section

Hi all,

Still got a problem to get it all work like i want.

I tried to use the code Els posted (see message above this one). I think i am doing something wrong, but it’s not working for me.

The code of my page template is:

<txp:output_form form="meta" />
<body>
<div id="wrapper">
<txp:output_form form="header+nav" />
<div id="content"> 
<div id="mainContent">
<txp:if_section name='default','club'/>
 <txp:if_category name=''>
   <txp:article_custom category='<txp:section/>' form="sticky" status="sticky" />
 <txp:else />
   <txp:article limit="5"/>
 </txp:if_category>
<txp:else />
 <txp:article limit="5"/>
</txp:if_section>
</div>
<div id="secondaryContent">
<h2>SecondaryContent</h2>
<p>Magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
</div>
</div>
<txp:output_form form="detail_nav"/>
<txp:output_form form="footer"/>

The result is that i got a error tag which says: Tag error: <txp:else /> -> Textpattern Warning: tag does not exist on line 1104
I think it has to do with the <txp:else/> after the </txp:if_category>

Another problem is that my page isn’t rendered as i want, because all the code of the page template after the </txp:section> isn’t displayed at all.

I hope somebody has an idea…….i am struggeling for a day with the problem and it drives me really mad…..

Thx in advance.

- Edited to make the code block stand out better.

Last edited by jstubbs (2009-01-26 21:11:29)


Kind regards,

Maarten

Offline

Board footer

Powered by FluxBB