Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-03-09 12:02:49

trenc
Plugin Author
From: Malmö
Registered: 2008-02-27
Posts: 572
Website GitHub

[howto] yab_navigation_template (3-level section based navigation template)

Note

This is not a plugin, so maybe this thread can be moved to »Howtos and Examples«. Don’t know which place is better.

Targets

I’ve wrote a tiny template, which can be used in most cases of navigation modes and styles. Demonstration

I had only two targets:

  • flexible
  • easy to use

What this mean?

Flexible
You can use this template for most navigation modes. So you can use it for simple one-level or two-level navigation. but you can use it for a 3-level navigation, too.

Easy to use
The output of the navigation structure depends only on the given or not given <txp:varaible />. Not more configuration is needed. So it can be used by users who are not so familar with different txp-tags.

What can I do with this

For instance you can easily create the following comlpex navigation strucure:

    * 1. Home
    * 2. Navpoint
          o 2.1 Navpoint
                + 2.1.1 Navpoint
                + 2.1.2 Navpoint
          o 2.2 Navpoint
                + 2.2.1 Navpoint
                + 2.2.2 Navpoint
          o 2.3 Navpoint
                + 2.3.1 Navpoint
                + 2.3.2 Navpoint
          o 2.4 Navpoint
          o 2.5 Navpoint
    * 3. Navpoint
          o 3.1 Navpoint
                + 3.1.1 Navpoint
                + 3.1.2 Navpoint
          o 3.2 Navpoint
                + 3.2.1 Navpoint
                + 3.2.2 Navpoint
          o 3.3 Navpoint
                + 3.3.1 Navpoint
                + 3.3.2 Navpoint
          o 3.4 Navpoint
          o 3.5 Navpoint
    * 4. Navpoint
          o 4.1 Navpoint
                + 4.1.1 Navpoint
                + 4.1.2 Navpoint
          o 4.2 Navpoint
                + 4.2.1 Navpoint
                + 4.2.2 Navpoint
          o 4.3 Navpoint
                + 4.3.1 Navpoint
                + 4.3.2 Navpoint
          o 4.4 Navpoint
          o 4.5 Navpoint
    * 5. Navpoint
    * 6. Navpoint

or a not so complex structure:

    * 1. Home
    * 2. Navpoint
          o 2.1 Navpoint
                + 2.1.1 Navpoint
                + 2.1.2 Navpoint
    * 3. Navpoint
    * 4. Navpoint

I’ve setup a small navigation demonstration with different css-styles, have a look!

And how does it work

Installing
You can grab the template here: yab_navigation_template

Copy the content in your navigation form or in your page.

Setup
In the head of the template are some <txp:variable /> entries. These you can setup with your needs.

<!-- Title of your Frontpage-Link -->
<txp:variable name="home_title" value="Home" />
<!-- Sort method for articles-->
<txp:variable name="sort" value="title asc" />
<!-- Your navigation structure-->
<txp:variable name="base_section" value="" />
    <txp:variable name="section1" value="" />
        <txp:variable name="section11" value="" />
        <txp:variable name="section12" value="" />
        <txp:variable name="section13" value="" />
    <txp:variable name="section2" value="" />
        <txp:variable name="section21" value="" />
        <txp:variable name="section22" value="" />
        <txp:variable name="section23" value="" />
    <txp:variable name="section3" value="" />
        <txp:variable name="section31" value="" />
        <txp:variable name="section32" value="" />
        <txp:variable name="section33" value="" />

Fill it with your corresponding sections and subsections. The order will be the displayed navigation order of the sections. If you want to change the article order by yourself you can change the <txp:variable name="sort" value="title asc" /> f.i. to <txp:variable name="sort" value="position asc" /> and use the great stm_article_order.

If you don’t need all sections, don’t remove it — only leave the value blank.

In your page place this:

<txp:if_individual_article>
	<txp:article />
<txp:else />
	<txp:article status="5" />
</txp:if_individual_article>

So the »section articles« (article, that represent the section site) have to be fixed and the others live.

That’s all.

Advantages and Disadvantages

Advantages

  • easy to use
  • fexible
  • with some txp-tag-experience it’s easily extendible, modifiable
  • active/passive css-classes on <li>
  • open/closed css-classes on <ul> (I know on <li> it would better but it’s not so easy to implement.)

Disadvantages

  • the URI structure will not represent your navigation structure by subsections (it’s a fake navigation)
  • if fully used it has more mysql-queries/load than a self coded/hardcoded or a subsection-menu plugin
  • it’s limited to a 3-level navigation (horizontal and in hierarchy/vertical), but can be enhanced if you are familiar with txp-tags

Credits

Nearly forgotten to thanks the Textpattern developer for the wunderfull new tagparser and espacially Robert (wet) who described a simple 2-way navigation which was the base for this template idea.

Last edited by trenc (2009-07-20 12:23:24)

Offline

Board footer

Powered by FluxBB