Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-16 11:12:07

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

category based submenu

i want to create category based submenus (dropdowns).

my current code

<txp:section_list active_class="active" wraptag="ul" break="li" default_title="Home" include_default="1" sections="articles,projects" class="horizontal">
<txp:section title="1" link="1" />
<txp:category_list type="article" wraptag="ul" break="li" section='<txp:section />' class="dropdown">
<txp:category title="1" link="1" />
</txp:category_list>
</txp:section_list>

which of course not working. it outputs all categories under each section. but i would like to display under each section only those categories which are associated with this section

Offline

#2 2009-12-16 12:18:46

cabes
Member
Registered: 2008-01-01
Posts: 28

Re: category based submenu

are your categories sorted by parent categories with the same names as the sections? If so, you could probably just add this to your category list tag: parent=”<txp:section />”

Offline

#3 2009-12-16 13:40:22

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: category based submenu

cabes wrote:

are your categories sorted by parent categories with the same names as the sections? If so, you could probably just add this to your category list tag: parent=”<txp:section />”

no, but does now and it really works :) . added exclude=’<txp:section />’ for not displaying parent category in category list as well

<txp:section_list active_class="active" wraptag="ul" break="li" default_title="Home" include_default="1" sections="articles,projects" class="horizontal">
<txp:section title="1" link="1" />
<txp:category_list type="article" wraptag="ul" break="li" section='<txp:section />'  parent='<txp:section />'  exclude='<txp:section />' class="dropdown">
<txp:category title="1" link="1" />
</txp:category_list>
</txp:section_list>

but only problem – no articles is displayed under those catergories :(

Offline

#4 2009-12-16 20:38:17

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

Re: category based submenu

Gallex wrote:

but only problem – no articles is displayed under those catergories :(

<txp:section_list active_class="active" wraptag="ul" break="li" default_title="Home" include_default="1" sections="articles,projects" class="horizontal">
   <txp:section title="1" link="1" />
   <txp:category_list type="article" wraptag="ul" break="li" section='<txp:section />' parent='<txp:section />'  exclude='<txp:section />' class="dropdown">
      <txp:category title="1" link="1" />
      <txp:article_custom category='<txp:category />' section='<txp:section />'>
         <txp:permlink><txp:title /></txp:permlink>
      </txp:article_custom>
   </txp:category_list>
</txp:section_list>

Offline

#5 2009-12-17 09:13:59

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: category based submenu

but now it displays article titles also in a submenu – i don’t want that. i would like to display only category titles in submenu like the code above does, but it outputs blank pages than i click on categories titles.

explained badly previously, sorry

Last edited by Gallex (2009-12-17 12:32:23)

Offline

#6 2009-12-17 20:17:49

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

Re: category based submenu

Ah sorry, I misunderstood you. You need a <txp:article /> tag on your page to display context sensitive articles or <txp:article_custom category='<txp:category />' section='<txp:section />' />.

Offline

#7 2009-12-18 11:05:14

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: category based submenu

Els wrote:

You need a <txp:article /> tag on your page to display context sensitive articles or <txp:article_custom category='<txp:category />' section='<txp:section />' />.

i have <txp:article /> tag on my page.
els, i noticed, that if to go a little bit around – clicking at first on a section (mainmenu) link and then on a category (submenu) link it displays articles, but then clicking directly on a category it doesn’t. the url’s are differrent. i would like to get directly into articles page

take a look yourself. it’s in top right

Offline

#8 2009-12-18 12:06:36

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

Re: category based submenu

Change this

<txp:category title="1" link="1" />

into

<txp:category title="1" link="1" section='<txp:section />' />

Last edited by els (2009-12-18 12:26:45)

Offline

#9 2009-12-18 13:02:21

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: category based submenu

absolutely perfect! thank you so much!

Offline

#10 2009-12-18 13:38:21

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: category based submenu

final code (maybe somebody wants to use it). remember, parent category names must be same as active section names.

<txp:section_list wraptag="ul" break="li" default_title="News" include_default="1" sections="articles,projects" class="horizontal">
<txp:section title="1" link="1" />
<txp:category_list type="article" wraptag="ul" break="li" section='<txp:section />' parent='<txp:section />' exclude='<txp:section />' class="dropdown">
<txp:category title="1" link="1" section='<txp:section />' />
</txp:category_list>
</txp:section_list>

Last edited by Gallex (2009-12-19 12:46:37)

Offline

Board footer

Powered by FluxBB