Trying to make a site with main/sub navigation

Get help with installation and running PivotX 2.0.x here. Please do not post Extension or Theme related questions here.

Trying to make a site with main/sub navigation

Postby thoro » Sat Mar 07, 2009 5:06 pm

Hello,

I'm trying to build a template for a standard website with main and subnavigation.

My idea is to use chapters for main navigation and pages for sub navigation - which means the chapter title displayed in the main navigation should link to the first page in this chapter. The sub navigation then shows all the pages of the currently active chapter. If there is only one page in a chapter, the sub navigation is not displayed.

I looked for a way to get a list of all chapters in the PivotX Documentation but I only found "getpagelist". Can I get an array with all chapters/pages and use PHP to build the navigation or is there a smarter way? Is it a good approach to use chapters/pages to manage my website structure?

Cheers

Thorsten
>www.thoro.de
>3DNP (3D - No Plugins)
thoro
 
Posts: 23
Joined: Sun Jan 27, 2008 11:42 am
Location: Berlin, Germany

Re: Trying to make a site with main/sub navigation

Postby Schop » Sun Mar 08, 2009 11:54 am

User avatar
Schop
Contributor
 
Posts: 485
Joined: Mon Apr 21, 2008 1:47 pm
Location: Hudson, Ohio

Re: Trying to make a site with main/sub navigation

Postby thoro » Sun Mar 08, 2009 1:07 pm

Ok, this lets me build a formatted list with all my chapter titles/page links/page titles.

For example:

[[ pagelist
chapterbegin="#main#%chaptername%"
pages="#sub#%title%$%link%"
chapterend=""
]]


gives me something like:

#main#About#sub#Contact$/page/contact#sub#Disclaimer$/page/disclaimer

But can I use PHP to parse this? I tried to put some PHP code into my template using [[php]] [[/php]] but it was ignored.

Thanks for your help

Thorsten
>www.thoro.de
>3DNP (3D - No Plugins)
thoro
 
Posts: 23
Joined: Sun Jan 27, 2008 11:42 am
Location: Berlin, Germany

Re: Trying to make a site with main/sub navigation

Postby Schop » Sun Mar 08, 2009 3:55 pm

Well, if that gives you what you want, you wouldn't have to use an extra [[php]] tag, right? Maybe I'm missing the point of what you said..
User avatar
Schop
Contributor
 
Posts: 485
Joined: Mon Apr 21, 2008 1:47 pm
Location: Hudson, Ohio

Re: Trying to make a site with main/sub navigation

Postby thoro » Sun Mar 08, 2009 5:16 pm

It gives me a string with all the information I need to make my main and sub navigation - but I have to use some kind of language to parse it because I want to work with dependencies like "If there's only on page inside a chapter, don't show the sub navigation".

Using PHP it would be a matter of 10 minutes to write the script and I read that it is possible to use PHP code within PivotX templates. But it just doesn't work - the [[PHP]] tags seem to be ignored.
>www.thoro.de
>3DNP (3D - No Plugins)
thoro
 
Posts: 23
Joined: Sun Jan 27, 2008 11:42 am
Location: Berlin, Germany

Re: Trying to make a site with main/sub navigation

Postby thoro » Mon Mar 09, 2009 3:05 pm

Ok, I discovered that I can turn on PHP parsing by setting the hidden configuration parameter "allow_php_in_templates" to "1".

And I can access template variables defined with [[ getpagelist var='testvar' ]] from PHP using $myVar = $this->get_template_vars('testvar');

But how can I access the chapter information? It seems like it is not possible to store the data returned by

[[ pagelist
chapterbegin="#main#%chaptername%"
pages="#sub#%title%$%link%"
chapterend=""
]]


in an variable like "getpagelist" does. And "getpagelist" doesn't seem to use "chapterbegin", "pages, "chapterend".

The information I found about if statements inside PivotX's template language won't let me realise my main / sub navigation without using an additional language like PHP.
>www.thoro.de
>3DNP (3D - No Plugins)
thoro
 
Posts: 23
Joined: Sun Jan 27, 2008 11:42 am
Location: Berlin, Germany

Re: Trying to make a site with main/sub navigation

Postby bramn » Mon Mar 09, 2009 3:36 pm

I think it's much easier to use some sort of Javascript framework or CSS hover and hide technique to accomplish your ideas. Can you give an example of what you're trying to achieve?
bramn
 
Posts: 33
Joined: Mon Nov 26, 2007 10:02 am
Location: Enschede, The Netherlands

Re: Trying to make a site with main/sub navigation

Postby thoro » Mon Mar 09, 2009 4:59 pm

Yes - I'd like to have a structure like this:

Chapter1 "About us"
-> Page1 "The Company"
-> Page2 "Contact"
-> Page3 "Legal Disclaimer"

Chapter2 "Products"
-> Page1 "Routers"
-> Page2 "Telephones"
-> Page3 "Misc"

Chapter3 "News"
-> Page1 "Current News"

I want to display a main navigation that shows buttons with the chapter's names - each entry is linked to the first page inside the chapter. For example if you click on "About us" the page "The Company" opens and the main navigation shows that you are inside "About us" and there is a sub navigation that shows the active page "About us" and the two other pages of this chapter.

If there is only one page in a chapter (as in "News") the sub navigation is not displayed - if I add a second page there will be a sub navigation for this chapter, too.

This would be a simple task for me in PHP - just because I'm used to it. All I need is an array with all my Chapter/Page/URL information that can be accessed by PHP - I don't like to rely on JavaScript.

If it can be done using PivotX's own template engine I'm happy with that. I just can't find an example for something like that in the documentation or in the forums.
>www.thoro.de
>3DNP (3D - No Plugins)
thoro
 
Posts: 23
Joined: Sun Jan 27, 2008 11:42 am
Location: Berlin, Germany

Re: Trying to make a site with main/sub navigation

Postby hansfn » Mon Mar 09, 2009 11:37 pm

OK, if you don't want to rely on JavaScript, why don't you write a simple PivotX extension based the smarty_pagelist code (that does exactly what you want)? You'll find smarty_pagelist in modules/module_smarty.php. Look in the extensions folder to see some example snippet extensions.
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: Trying to make a site with main/sub navigation

Postby seb » Tue Mar 10, 2009 11:54 am

Hej Thoro,

You have exactly the same wish as I have (see the link in the first reaction). The Idea is to create a way to have an easy menu functioning for "dummy pivotx users". So even they can change the menu without much more struggle.

I am half way; created it like this

Chapter: english menu
page: we
page: work
page: contact

Chapter: swedish menu
page: oss
page: arbet
page: kontakt

Chapter: we
page: who
page: people
osv

Use the chapterstart & chapterend to show the menu's
And then use them again for showing just the subpages in a secondairy menu.

The only thing not working (I haven't got the time to look at it some more) is to get it to show the right subpages of "we" when I choose the page "we".
seb
 
Posts: 77
Joined: Wed Jan 16, 2008 12:34 pm

Next

Return to 2.x Support Forum

Who is online

Users browsing this forum: No registered users and 5 guests

cron