hierarchical menu

Discuss PivotX 2.0.x extensions here, and view extensions that are available for download.

hierarchical menu

Postby rabbeltje » Tue Apr 27, 2010 12:52 pm

so, i've added and installed the hierarchical menu-extension/hook, and it's working (pretty much). i have one question though: is there a way to only show the sublevel-items of the current chapter?

i have the following structure (only a part of it, posting all would be a bit long here 8-) ):
Code: Select all
Chapter 'base':
  - page 'homepage'
  - page 'slofjes'
  - page 'mutsen'
 
Chapter 'homepage'
  - page 'home'

Chapter 'slofjes'
  - page 'slofjes1'
  - page 'slofjes2'

Chapter 'mutsen'
  - page 'mutsen1'
  - page 'mutsen2'

etc...


so, say i am looking at slofjes1, is there a way to stop the menu from showing the items under mutsen? i've tried the topnav-extension and the subnav-extension, but they don't offer the structure the menu-extension offers (ie they put the pages underneath the entire list of chapters instead of underneath 'their own' chapter if that makes any sense!)

edit: forgot the link to the site: han-d-made.rabbeltje.nl (the design is a terrible scramble of a work-in-progress! don't pay attention to it...)

2nd edit: i've already come to the conclusion that this is not my solution anyway, but i'd still like the answer for possible future use if possible ;) so never mind checking the link, i've already removed the code ;)
User avatar
rabbeltje
 
Posts: 358
Joined: Mon Aug 25, 2008 11:54 am
Location: Neerbeek, The Netherlands

Re: hierarchical menu

Postby hansfn » Thu Apr 29, 2010 12:56 pm

You can fix it using CSS or Javascript. If you use this JQuery menu code and the following template code:

Code: Select all
            [[ menu
                firstchapter="the index chapter"
                toplevelbegin="<ul class='menu collapsible'>"
                sublevelbegin="<ul class='acitem'>"
                isactive="class='active'"
            ]]

you get something that is pretty close to what you want.
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: hierarchical menu

Postby rabbeltje » Thu Apr 29, 2010 1:11 pm

that looks pretty good! thanks!
User avatar
rabbeltje
 
Posts: 358
Joined: Mon Aug 25, 2008 11:54 am
Location: Neerbeek, The Netherlands

Re: hierarchical menu

Postby rabbeltje » Mon May 17, 2010 1:30 pm

i have another question regarding this...

i've been fiddling with the code you gave me, and it's somewhat working... but not entirely :( as soon as i click any of the listed pages, the menu returns to a collapsed state. maybe i'm just missing something really simple, but i can't seem to figure out how to keep the menu expanded for the chapter the page i'm looking at belongs to. if that makes any sense...

link: http://han-d-made.rabbeltje.nl/
Last edited by rabbeltje on Tue May 18, 2010 6:45 am, edited 2 times in total.
User avatar
rabbeltje
 
Posts: 358
Joined: Mon Aug 25, 2008 11:54 am
Location: Neerbeek, The Netherlands

Re: hierarchical menu

Postby hansfn » Mon May 17, 2010 6:55 pm

No, you aren't missing something. You need to modify the Javascript slightly. (I'm planning on getting this modification accepted by the author.) Grab my version of the jQuery code.

PS! You can see an example in my dev/test weblog that uses the menu template code that I posted above and the modified jQuery code.
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: hierarchical menu

Postby rabbeltje » Tue May 18, 2010 6:38 am

thanks!!
User avatar
rabbeltje
 
Posts: 358
Joined: Mon Aug 25, 2008 11:54 am
Location: Neerbeek, The Netherlands

Re: hierarchical menu

Postby rabbeltje » Tue May 18, 2010 8:31 am

here i am again ;)

i have an extra-image assigned to all my pages. i would like to show a miniature of that image in the list of pages but so far, no luck. i can get a list of these images with this code:
Code: Select all
            [[ getpagelist var='pagelist' onlychapter=$page.chaptername ]]
            [[ foreach from=$pagelist item='pageuri' ]]
            [[ getpage uri=$pageuri ]]
      
            <a href='[[ $page.link ]]'>[[ image file=$page.extrafields.image alt=$page.extrafields.description class="artikel"]]</a>

            [[ resetpage ]]
            [[ /foreach ]]


so i figured with
Code: Select all
<a href='[[ $page.link ]]'>[[ image file=$page.extrafields.image alt=$page.extrafields.description class="artikel"]]</a>
i should get something similar, but it just gives me a bunch of code instead if images or a broken image. is there any way i can achieve this, am i missing something, is it undoable..? thanks for any help!
User avatar
rabbeltje
 
Posts: 358
Joined: Mon Aug 25, 2008 11:54 am
Location: Neerbeek, The Netherlands

Re: hierarchical menu

Postby hansfn » Tue May 18, 2010 9:00 am

Yes, you get

Code: Select all
<img src="Array.extrafields.image" class="artikel" />

Your code should have worked. MySQL or flatfile db? To understand some more, please add

Code: Select all
[[ print_r var=$page ]]

next to the link so we can see the content of $page.
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: hierarchical menu

Postby rabbeltje » Tue May 18, 2010 9:19 am

i'm using mysql, revision 2697.

i added the code, this is what it says: (from a random page)
Code: Select all
Array
(
    [uid] => 17
    [title] => lief beestje
    [uri] => lief-beestje
    [subtitle] =>
    [introduction] =>
lieveheersbeestje, uniek, kadootje, baby, peuter


    [body] =>
Een lief klein vriendje voor iedereen!


    [convert_lb] => 5
    [template] => -
    [status] => publish
    [date] => 2010-04-07 07:17:00
    [publish_date] => 2010-04-07 07:17:00
    [edit_date] => 2010-05-06 06:54:57
    [chapter] => 8
    [sortorder] => 2
    [user] => rabbeltje
    [allow_comments] => 0
    [keywords] =>
    [extrafields] => Array
        (
            [image] => 2010-04/foto0228.jpg
            [materiaal] => 100% acryl
            [methode] => gehaakt
            [prijs] => €15,-
            [afmetingen] => +/- 12 cm
        )

    [link] => /?p=lief-beestje
    [chaptername] => knuffels
)


--


edit: this is the code i have in my template at the moment (which doesn't work...):
Code: Select all
         [[ menu
            firstchapter="base"
            toplevelbegin="<ul class='menu'>"
            sublevelbegin="<ul class='acitem'>"
            sublevelitem="<li %active%><a href=%link%>[[ image file=$page.extrafields.image alt=$page.extrafields.description class="artikel"]]</a>[[ print_r var=$page ]]</li>"
            isactive="class='active'"
         ]]


using [[ $page.link ]] doesn't work at all, so i changed it back to %link%. this code returns the code where the image should be. i also tried
Code: Select all
<img src="[[$page.extrafields.image]]" />
which i found in the documentation for the extrafields extension, that code returned the broken image.
User avatar
rabbeltje
 
Posts: 358
Joined: Mon Aug 25, 2008 11:54 am
Location: Neerbeek, The Netherlands

Re: hierarchical menu

Postby hansfn » Tue May 18, 2010 9:39 am

Now you are doing many things at the same time ... You posted an example using getpagelist and a foreach loop with getpage. It was in the connection I wanted you to test "[[ print_r var=$page ]]". Using the $page variable in the menu template tag doesn't work - neither does nested template tags. We could expand the menu tag to accept "%page.link% and so on, but $page.link and similar will never work.
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Next

Return to 2.x Extensions

Who is online

Users browsing this forum: No registered users and 1 guest

cron