Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
children of current page
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
93-interactive  
View profile  
 More options Dec 5 2011, 10:23 am
From: 93-interactive <93interact...@googlemail.com>
Date: Mon, 5 Dec 2011 07:23:42 -0800 (PST)
Local: Mon, Dec 5 2011 10:23 am
Subject: children of current page
Hi,

zotonic 0.7.1:

from within a template, how can i get the children of the current
page, as defined in the main_menu?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Stenius  
View profile  
 More options Dec 6 2011, 5:38 am
From: Andreas Stenius <andreas.sten...@astekk.se>
Date: Tue, 6 Dec 2011 11:38:40 +0100
Local: Tues, Dec 6 2011 5:38 am
Subject: Re: [Zotonic-Dev] children of current page
You can get the complete menu structure from the menu property of a
menu resource.

Example for the main_menu:

1: {% print m.rsc.main_menu.menu %}
2: {% print m.rsc.main_menu.menu|menu_flat %}

Sample output:

1: [{360,[]},{316,[{314,[]},{315,[]}]}]

2: [{360,[1],undefined},
 {316,[2],down},
 {314,[1,2],undefined},
 {315,[2,2],undefined},
 {undefined,undefined,up}]

Which you the may traverse with a for loop, looking for you current
id, and the from there you have the children...
I leave it as an exercise... ;c)

//Andreas

2011/12/5 93-interactive <93interact...@googlemail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
93-interactive  
View profile  
 More options Dec 6 2011, 8:20 am
From: 93-interactive <93interact...@googlemail.com>
Date: Tue, 6 Dec 2011 05:20:27 -0800 (PST)
Local: Tues, Dec 6 2011 8:20 am
Subject: Re: children of current page
Hi,

On Dec 6, 11:38 am, Andreas Stenius <andreas.sten...@astekk.se> wrote:

thank you, unfortunately i still have trouble understanding it, i
should mention, that i am new, both to erlang and zotonic.

As i understand it, result 2 gives me all available id's in list
position [1] and the position within result 1 in list position [2]
(reverse).

So i have two problems here. Result 2 gives me numbers, whereas result
1 gives me names where available and numbers where not, so i can not
match all entries.

Example from my site:

1)

[{page_home,[]},{page_about,[]},{page_contact,[]},{331,[{336,[]},{332,
[]}]}]

2)

[{312,[1],undefined},
 {313,[2],undefined},
 {314,[3],undefined},
 {331,[4],down},
 {336,[1,4],undefined},
 {332,[2,4],undefined},
 {undefined,undefined,up}]

Even if i could, i would still have the problem that i have a reverse
position list, e.g. [1,2] for 314, which within the template, i do not
know how to apply to get the children from result 1.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
93-interactive  
View profile  
 More options Dec 7 2011, 3:44 am
From: 93-interactive <93interact...@googlemail.com>
Date: Wed, 7 Dec 2011 00:44:13 -0800 (PST)
Local: Wed, Dec 7 2011 3:44 am
Subject: Re: children of current page
Ok, so after reinstalling everything on the production server and
starting from scratch
for some reason it gets me all numeric indices:

1)

[{316,[{318,[]},{319,[]}]},{317,[]}]

2)

[{316,[1],down},
 {318,[1,1],undefined},
 {319,[2,1],undefined},
 {undefined,undefined,up},
 {317,[2],undefined}]

So what i have so far:

{% for page,pos,rest in m.rsc.main_menu.menu|menu_flat %}
        {% if page /= undefined %}
                {{ page }} on {{ pos }} <br />
        {% endif %}
{% endfor %}

what i would need now in instead the {{ page }} on {{ pos }} line
something like

m.rsc.main_menu.menu[pos]

That gives me the children, but i did not find a way to achieve this,
any ideas?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Stenius  
View profile  
 More options Dec 7 2011, 7:43 am
From: Andreas Stenius <andreas.sten...@astekk.se>
Date: Wed, 7 Dec 2011 13:43:02 +0100
Local: Wed, Dec 7 2011 7:43 am
Subject: Re: [Zotonic-Dev] Re: children of current page
The flat structure tells you when to go down, and when to come back up.
See the _menu.tpl file for how the menu is rendered in zotonic.
https://github.com/zotonic/zotonic/blob/master/modules/mod_menu/templ...

So, to only include the children of the current page (if any), you
could do something along the lines of (assuming the current page id is
in variable "id"):

{% for page_id, path, action in m.rsc.main_menu.menu|menu_flat %}

  {% if id = page_id and action = "down" %}   {# no children unless
action is down #}

  {% endif %}

{% endfor %}

Hmm... this becomes quite hard to do with only templating... why not
write a simple filter to return just the children of a given id?

What end result are you looking for?

I didn't quite understand your intention with "m.rsc.main_menu.menu[pos]".

//Andreas

2011/12/7 93-interactive <93interact...@googlemail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
93-interactive  
View profile  
 More options Dec 8 2011, 6:00 am
From: 93-interactive <93interact...@googlemail.com>
Date: Thu, 8 Dec 2011 03:00:14 -0800 (PST)
Local: Thurs, Dec 8 2011 6:00 am
Subject: Re: children of current page
Hi,

On Dec 7, 1:43 pm, Andreas Stenius <andreas.sten...@astekk.se> wrote:

> Hmm... this becomes quite hard to do with only templating... why not
> write a simple filter to return just the children of a given id?

because i am new and don't know how to do things on zotonic ;-)

Changed it to filter, got it work, thank you.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andreas Stenius  
View profile  
 More options Dec 8 2011, 7:15 am
From: Andreas Stenius <andreas.sten...@astekk.se>
Date: Thu, 8 Dec 2011 13:15:56 +0100
Local: Thurs, Dec 8 2011 7:15 am
Subject: Re: [Zotonic-Dev] Re: children of current page
2011/12/8 93-interactive <93interact...@googlemail.com>:

> [...] Changed it to filter, got it work, thank you.

Cool :-)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »