Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-05-27 22:45:44

Szorstki
Member
From: Poland
Registered: 2012-05-27
Posts: 20

Fighting with much complicated menu

Hi everyone! I’m creating a website for a bank, and I need quite complicated menu with structure:
  • Home
  • Services (section; and I created the same category)
    • list of articles from this section in dropdown menu – the only list of articles (titles) in menu
  • Offers (section; and I created the same category)
    • for provate consumers (a subcategory; this and below are subcategories of “Offers”)
    • for business (subcategory)
    • for agriculture (subcategory)
  • Products (section; and I created the same category)
    • Credit Cards (subcategory of Products)
    • … – other subcategories
  • About
  • Contact

I’ve combined some code from this forum and other tutorials modified by myself (I’m new in TXP) and get something like this:

<div id="search"><txp:search_input button="szukaj" label="0" wraptag="0"/></div>
<div class="menu">
    <a href="<txp:site_url />" alt="<txp:site_name/>"><txp:image html_id="logo" id="5" /></a>
    <txp:section_list active_class="active" default_title='<txp:text item="home"/>' include_default="1" wraptag="ul" break="li" sections="uslugi, oferta, produkty, o-banku, kontakt">
   		<txp:section title="1" link="1" />
    	<txp:category_list children="0" parent='<txp:section />' exclude='<txp:section />' break="li" wraptag="ul"/>
	</txp:section_list>
	<div class="cleaner"></div>
</div>

The same on PasteBin with XML highlitgh – services, offers, etc. are replaced by polish names but I hope it’s clear.
Everything except creating a list of articles (submenu) in services works. How do I render listing of articles only for one section in menu? I’ve tried IF_SECTION, but it work only if I’m in localhost\mytxpsite\services and render the same submenu for every section…
Any ideas?
.

Offline

#2 2012-05-27 23:44:45

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Fighting with much complicated menu

Hi Szorstki, if you’re happy to use sections instead of categories then adi_menu is one option.

Offline

#3 2012-05-27 23:50:30

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

Re: Fighting with much complicated menu

You are right, you can’t create a menu like that with just the section_list tag, try something like this:

   <ul>
      <li<txp:if_section name=""> class="active">><txp:link_to_home><txp:text item="home" /></txp:link_to_home></li>
      <li<txp:if_section name="uslugi"> class="active">><txp:section name="uslugi" title="1" link="1" />
         <ul>
            <txp:article_custom section="uslugi"><li><txp:permlink><txp:title /></txp:permlink></li></txp:article_custom>
         </ul>
      </li>
      <txp:section_list active_class="active" wraptag="" break="li" sections="oferta, produkty, o-banku, kontakt">
         <txp:section title="1" link="1" />
         <txp:category_list children="0" parent='<txp:section />' exclude='<txp:section />' break="li" wraptag="ul" />
      </txp:section_list>
   </ul>

Edit: unless you are going for adi_menu of course ;)

Last edited by els (2012-05-27 23:51:05)

Offline

#4 2012-05-28 18:15:58

Szorstki
Member
From: Poland
Registered: 2012-05-27
Posts: 20

Re: Fighting with much complicated menu

I thought about “hardcoding” the menu, but I’m used to PHP and take section_list as a loop by sections :)
I’ll probably use adi_menu, it will do the job as I see in documentation. But first I’ll finish templates and forms, then improve menu.

Thanks for posting solutions :)

Offline

Board footer

Powered by FluxBB