Welcome, Guest. Please login or register.
Did you miss your activation email?
14 Mar 2010, 08:34

Login with username, password and session length
Home Chat Help Search Calendar Login Register
Pages: [1]
Print
Author Topic: CTLModuleMaker - Header Menu & Item List [SOLVED]  (Read 251 times)
0 Members and 1 Guest are viewing this topic.
crankshaft
Forum Members
**

Karma: 0
Offline Offline

Posts: 34


« on: 01 Jul 2009, 08:03 »

I just can't seem to solve this, what I need is a page (every page) that has the (active) top level displayed as a horizontal menu, with links to lists of the children for the parent selected.

The CSS formatting of the lists is not a problem, but getting the child list is.

{cms_module module="my_menus" what="parent"}
{foreach from=$itemlist item="item"}
   <li {if $item->is_selected}class="active"{/if}>{$item->detaillink}</li>
{/foreach}

"{cms_module module="my_menus" what="parent"}" does print the top level active menus correctly, but when I click on one of the top level menus, instead of getting a list of children for the selected parent, what I get is a another list of the top level parents ?!

Any help gratefully accepted :-)

Thanks

P



« Last Edit: 02 Jul 2009, 20:54 by crankshaft » Logged
crankshaft
Forum Members
**

Karma: 0
Offline Offline

Posts: 34


« Reply #1 on: 02 Jul 2009, 07:22 »

Bump....

Can someone help please ??

I need a template that has a list of top level items, and the same template lists the children of the selected parent.

The key thing is to always display all the active top level items, and only the children of the top parent selected.

Thanks

P
Logged
plger
Forum Members
**

Karma: 11
Offline Offline

Posts: 183



« Reply #2 on: 02 Jul 2009, 09:16 »

Hi,
I take it you first call your module from the page using:
{cms_module module="my_menus" what="child"} and that the template you've given has been set default template for the child level?
Technically I don't see what this wouldn't work (though I'll take a look at it), but I believe it would be more simple to call the module twice independently. For example, you could have your page template (roughly) :

(header stuff)
{cms_module module="my_menus" what="parent"}
{content}
(footer stuff}

and then call the item list as the content of your page :
{cms_module module="my_menus" what="child"}
(without the call to parents in the module template)

Then, as links default to inline, when you'll click on a parent, the module action will replace the content, so you'll get what you're looking for.

Pierre-Luc
Logged
crankshaft
Forum Members
**

Karma: 0
Offline Offline

Posts: 34


« Reply #3 on: 02 Jul 2009, 09:59 »

Hi;

Thanks for the suggestions.

I'd actually tried calling the module twice in the page content, but the problem is, the page where the module is called twice is replaced by the template as soon as a parent is selected, and so it only works for the very first page.

I have tried lots of things including module queries and passing the output of the parent to a UDT and then trying to display the UDT for the header (parent menus) nut that just crashes the template.

I've tried calling templates inside templates but that does not work either, I'm stumped.

Just to summarize, in the same template, I need a list of all of the top level items to be always displayed, and also a list of the children of the selected parent, all in the same template.

As mentioned, this all needs to be done in the template, as the template over-writes the original page {content} which it was called from, and it looks like a template can only display the parent list or the child list but not both !

Thanks

P




« Last Edit: 02 Jul 2009, 11:28 by crankshaft » Logged
plger
Forum Members
**

Karma: 11
Offline Offline

Posts: 183



« Reply #4 on: 02 Jul 2009, 13:00 »

I'd actually tried calling the module twice in the page content, but the problem is, the page where the module is called twice is replaced by the template as soon as a parent is selected, and so it only works for the very first page.

Obviously. That's why I said to place the parent menu in the page template and the item list in the page content.
Logged
crankshaft
Forum Members
**

Karma: 0
Offline Offline

Posts: 34


« Reply #5 on: 02 Jul 2009, 20:53 »

Thanks;

The result is the same, the page content {content} tag is overwritten by the module, so anything which you put in the page content will disappear once one of the module's links are clicked.

So anyway, I could not find a solution that worked using just the page content and the module, so came up with a solution that works by modifying the main template and adding a bit of javascript /DOM.

Here's a summary of what I did:

1) Add a new <div> just above the {content} tag:
Code:
<h2>{title}</h2>
<div id="parents" style="display:none;">{cms_module module="my_module" what="menu" listtemplate="my_template"}</div>
{content}

2. Create  a new Global Content Block: {global_content name='show_menus'}
Code:
{literal}
<script type="text/JavaScript">document.getElementById('parents').style.display = '';</script>
{/literal}

3. In the template that you use for the child list add the global content block:
Code:
{global_content name='show_menus'}

4. In your Page Content which displays the child lists (the initial page which gets over-written) also add the gcb:
Code:
{global_content name='show_menus'}

This works, by hiding the additional div on all other pages except for the ones loaded with the module template and the main page itself where you call the module from.

I really wanted to do it this way in the main template:
Code:
<h2>{title}</h2>
{if $page == "my_display"}<div><div id="parents">{cms_module module="my_module" what="menu" listtemplate="my_template"}</div></div>{/if}
{content}

But that again only works the first time the page is loaded, as the $page variable no longer contains the name of the page alias after a link is clicked, but a number which is generated by the module with the "&cntnt01returnid" GET variable.


Logged
plger
Forum Members
**

Karma: 11
Offline Offline

Posts: 183



« Reply #6 on: 02 Jul 2009, 23:31 »

The result is the same, the page content {content} tag is overwritten by the module, so anything which you put in the page content will disappear once one of the module's links are clicked.
Once again, that's why you must put it NOT in the page content, but in the page template.

If your site is online and if you wish, give me an editor access to your cms and I will do it.
Logged
Pages: [1]
Print
Jump to: