Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-09-24 14:26:17

tranglos
Member
From: Poland
Registered: 2005-08-21
Posts: 11
Website

Multi-level menu, possible?

I’m trying to create a menu for a personal freeware site, with more than one level of nesting, such as:

Products
—— Product A
———— Features
———— Screenshots
———— Download
—— Product B
———— Features
———— Screenshots
———— Download
etc

Now, “Products” would be a section in TXP terms (there will be other sections at the top level), while level-3 items (Features, Screenshots, Download) are articles. I can’t see how to get the middle level though, since sections cannot be nested, and categories don’t “belong” to sections, either.

Another requirement is for the menu to expand dynamically, i.e. only the currently active item should show sublevels. This is because I have 9 apps on my site, and there are about 5-6 individual pages for each, so the complete menu is rather large.

Is there a way to do this in TextPattern?

Last edited by tranglos (2009-09-24 14:26:38)


Well I can get the ‘a’. But how do I put the circle around it?

Offline

#2 2009-09-24 15:31:08

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,732
Website

Re: Multi-level menu, possible?

An alternative way of organising things would be:

  • have a section named “products”
  • make an article per product with the features
  • upload the screenshots to the image tab and give them an image category that matches the name of the product (e.g. make it match the article_url_name exactly). Use a gallery plugin such as smd_gallery or rss_thumbpop or one of the many others to show an image gallery that uses the image category with the same name as the article_url.
  • upload the downloads to the file tab. Either use the same principle with categories if you have several downloads per product or use a plugin such as upm_file to ‘attach’ the file number to your article.

With this setup you don’t need separate pages (articles) for the different features/screenshots/downloads. If you want to you could divide your page template into a series of divs with features (txp:body), screenshot gallery (the image category gallery) and file downloads (the file category or linked file) and then use something like jquery tabs – for example these – to divide the page into three visual sections. I believe you can bookmark these tabs allowing you to create links that switch directly to the relevant tab.

You can then make your menu using a normal txp:section_list in combination with txp:article_custom (check www.txptips.com for various menu setups). Your features, screenshot and download links are simply the txp:permlink of the article with #features, #screenshots or #download appended to the link.

Last edited by jakob (2009-09-24 15:34:22)


TXP Builders – finely-crafted code, design and txp

Offline

#3 2009-09-24 15:39:55

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

Re: Multi-level menu, possible?

To create the menu: create parent categories with the same name as your sections (in your example ‘products’) and add your categories to them. To display the menu something like this might work (not tested, and you’ll probably need to add some attributes, change wraptags etcetera):

<txp:section_list break="">
	<h3><txp:section title="1" link="1" /></h3>
	<txp:category_list parent='<txp:section />' exclude='<txp:section />' section='<txp:section />' break="">
		<h4><txp:category title="1" link="1" section='<txp:section />' /></h4>
		<txp:article_custom category='<txp:category />' section='<txp:section />' wraptag="ul" break="li">
			<txp:permlink><txp:title /></txp:permlink>
		</txp:article_custom>
	</txp:category_list>
</txp:section_list>

For the expand function have a look at jQuery, or I’ll leave it to someone else to point you to a solution ;) It’s perfectly doable.

(edit: Jakob was faster ;) )

Last edited by els (2009-09-24 15:41:28)

Offline

#4 2009-09-24 15:44:09

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: Multi-level menu, possible?

Although multilevel menus are possible, your example could easier be achieved using a single article per product and some clever use of custom fields.

If you have a couple of products or 10 without any scope to expand then a parent category per product with articles for each category would do it but if you will eventually have a lot of products this would become very messy and hard to maintain.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2009-09-24 15:50:57

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Multi-level menu, possible?

Slowest still! But here’s yet another idea.

Seems very similar to Benoit’s request here. Here’s an idea (untested):

  1. Make a custom field called Product
  2. For each product, make 4 articles:
    • Main
    • Features
    • Screenshots
    • Download
  3. Enter the product name in the Product custom field for each of the 4 articles
  4. Assign each article its category (main, features, screenshots, download)

Here’s your menu:

<txp:article_custom category="main" wraptag="ul" break="li">
<txp:permlink><txp:title /></txp:permlink>
<txp:article_custom product='<txp:custom_field name="product" />' wraptag="ul" break="li">
<txp:if_article_category name="main"><txp:else />
<txp:permlink><txp:title /></txp:permlink>
</txp:if_article_category>
</txp:article_custom>
</txp:article_custom>

This is an elaboration of the method I describe in this article I just posted yesterday.

Last edited by jsoo (2009-09-24 16:32:55)


Code is topiary

Offline

#6 2009-09-24 15:55:38

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

Re: Multi-level menu, possible?

tranglos, you have a choice ;) jsoo, the link to your article doesn’t work, and I’m curious…

Offline

#7 2009-09-24 16:22:31

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: Multi-level menu, possible?

I think jeff meant to post this

I didn’t notice that others have answered before me… Serves me right for keeping your post open whilst trying to multi-task


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#8 2009-09-24 16:34:22

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Multi-level menu, possible?

colak wrote:

I think jeff meant to post this…

Funny, the other link worked for me …

D’OH!

Thanks!


Code is topiary

Offline

#9 2009-09-24 18:19:05

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,732
Website

Re: Multi-level menu, possible?

just great to see how many routes lead to Rome :-)

jeff, yours is probably closest to tranglos’ original suggestion, although I think with that structure one will end up with a lot of similarly-named articles, some of which – e.g. screenshots or download – will probably contain very little actual content unless one hand-codes screenshot galleries in textile (a bit laborious).

This is an elaboration of the method I describe in this article I just posted yesterday

Thanks to the pointer to your article. I looked at your multidoc plugin once before for a somewhat simpler solution and then decided it would be a sledgehammer to crack a nut. Your post offers a nice solution. In that particular case I ended up using a custom field with related IDs as the sort order was important (though one can also achieve that by adjusting the posted date).


TXP Builders – finely-crafted code, design and txp

Offline

#10 2009-09-24 18:38:30

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Multi-level menu, possible?

jakob wrote:

jeff, yours is probably closest to tranglos’ original suggestion, although I think with that structure one will end up with a lot of similarly-named articles, some of which – e.g. screenshots or download – will probably contain very little actual content unless one hand-codes screenshot galleries in textile (a bit laborious).

Right — not knowing what was planned for the screenshot, features, and download articles I took the OP at his word that these should be articles.

However, my code doesn’t work. This does:

<txp:if_individual_article>
   <txp:variable name="this_id" value='<txp:article_id />' />
   <txp:article_custom category="main" wraptag="ul" break="li">
      <txp:permlink><txp:title /></txp:permlink>
      <txp:if_variable name="this_id" value='<txp:article_id />'>
         <txp:article_custom product='<txp:custom_field name="product" />' wraptag="ul">
            <txp:if_variable name="this_id" value='<txp:article_id />'>
            <txp:else />
               <li><txp:permlink><txp:title /></txp:permlink></li>
            </txp:if_variable>
         </txp:article_custom>
      </txp:if_variable>
   </txp:article_custom>
<txp:else />
   <txp:article_custom category="main" wraptag="ul" break="li">
      <txp:permlink><txp:title /></txp:permlink>
   </txp:article_custom>
</txp:if_individual_article>

Horrible lot of code for a menu, but the article-within-article gets confusing. It might be possible to streamline this?


Code is topiary

Offline

#11 2009-09-24 22:01:21

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

Re: Multi-level menu, possible?

There’s always the “sub-sections” approach: adi_menu

Offline

Board footer

Powered by FluxBB