Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-08-22 07:32:31

arnski
Archived Plugin Author
From: Hamburg, Germany
Registered: 2007-08-21
Posts: 21
Website

Adaptable 2-Level Navigation-Menu with Highlighting

Hi – almost giving up on this “supposed to be” simple task:

I want to create a Site for a customer that wants to be abled to change every bit of text on it, as well as add pages etc..

The main problem for me right now is to come up with the right way to build the menu.

it should look like this:

  • Section1
  • Section2
  • _ Category1 (These Categories only show up, if Section2 ist the active Section)
  • _ Category2
  • Section3
  • Section4

Of course, the active section should be highlighted, as well as the active category.

This is what i came up with so far:

<txp:section_list active_class="menue_links_on" class="menue_links_off" include_default="0" sections="Firmenportrait,Produkte,Partner,Kontakt" /><br />
<txp:if_section name="produkte"><txp:category_list active_class="menue_links_on" class="menue_links_off" categories="Konzept,Produktkategorie-1,Produktkategorie-2" section="produkte" type="article" /></txp:if_section>

which produces the following:

* Section1
* Section2
* Section3
* Section4
* Category1 
* Category2

So my 1st question would be: 
How do i get the categories in the place where they should be - preserving the highlighting?

2nd question:
Is there anything wrong with my  txp:category_list-code? Because if i klick on one category it should get "assigned" the menue_links_on-class, which oddly enough it does'nt.

Any comments very appreciated.

Arne

Oops, that looked different in the preview! How do i end the forum-codeblock? And yes i read the quick-help.

Last edited by arnski (2007-08-22 07:35:32)

Offline

#2 2007-08-22 10:07:51

arnski
Archived Plugin Author
From: Hamburg, Germany
Registered: 2007-08-21
Posts: 21
Website

Re: Adaptable 2-Level Navigation-Menu with Highlighting

Anyone?

Well – i found the solution for my 2nd Question myself: I think it’s a bug in TXP.

I had to change Line 926 in the taghandlers.php from

( ($active_class and ($c == strtolower($name))) ? ' class="'.$active_class.'"' : '' ).

to

( ($active_class and (strtolower($c) == strtolower($name))) ? ' class="'.$active_class.'"' : '' ).

adding the strtolower also for the $c- Variable which seems to make sense, does’nt it?

Still question Number 1 remains – please, anyone?

Offline

#3 2007-08-22 10:12:33

arnski
Archived Plugin Author
From: Hamburg, Germany
Registered: 2007-08-21
Posts: 21
Website

Re: Adaptable 2-Level Navigation-Menu with Highlighting

Also – something seems wrong with this Forum, too.

When I look at my Post and first reply in this thread, the author-name states “alpha”, when clearly it should state “arnski”, or not?

Offline

#4 2007-08-22 10:15:36

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Adaptable 2-Level Navigation-Menu with Highlighting

Your name is visible as well. ‘alpha’ means that you haven’t posted a lot on this forum yet. You grow from ‘alpha’ to ‘beta’ to …

That bug you mention will be fixed in the next 4.0.x version, but you can easily work around it by setting the section/category name to all lowercase (you can still keep the section/category title with an capital letter at the beginning).

The answer to your first question is: write a plugin.

Offline

#5 2007-08-22 10:16:39

arnski
Archived Plugin Author
From: Hamburg, Germany
Registered: 2007-08-21
Posts: 21
Website

Re: Adaptable 2-Level Navigation-Menu with Highlighting

Or are my posts considered to be alpha, since i am a nubee here?

When will i get beta-status?

;)

Offline

#6 2007-08-22 10:23:21

arnski
Archived Plugin Author
From: Hamburg, Germany
Registered: 2007-08-21
Posts: 21
Website

Re: Adaptable 2-Level Navigation-Menu with Highlighting

ruud wrote:

Your name is visible as well. ‘alpha’ means that you haven’t posted a lot on this forum yet. You grow from ‘alpha’ to ‘beta’ to …

you beat me to it 8)

ruud wrote:


That bug you mention will be fixed in the next 4.0.x version, but you can easily work around it by setting the section/category name to all lowercase (you can still keep the section/category title with an capital letter at the beginning).

O.K – that seems like a better approach than to alter the txp-sources

ruud wrote:


The answer to your first question is: write a plugin.

This sounds like i don’t like it :( Is there a good place to start, or a similar Plugin i could take a peek at?

Dankeschön, Ruud (^-^)

Last edited by arnski (2007-08-22 10:24:58)

Offline

#7 2007-08-22 10:35:39

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Adaptable 2-Level Navigation-Menu with Highlighting

textbook documentation on plugin development

Take a look at similar section/category list plugins at textpattern.org or just take the section_list code from the TXP code (textpattern/taghandlers.php), combine that with your wishes and put it into a plugin. If you can debug TXP code, you can probably write a plugin ;)

Offline

#8 2007-08-23 16:28:48

arnski
Archived Plugin Author
From: Hamburg, Germany
Registered: 2007-08-21
Posts: 21
Website

Re: Adaptable 2-Level Navigation-Menu with Highlighting

.. And i did ()

Here’s my first plugin: zoo_section_and_category_list

And here’s the included help:

Adaptable 2-Level Navigation-Menu with Highlighting

This plugin tries to accomplish the following:

  • Building a 2-Level Navigation-Menue using a single TXP-tag.
  • 1st Level should consist of sections, 2nd level of categories
  • Keep the 2nd level adaptable, meaning it’s contents should be controllable from users without access to and knowledge of the “Presentation”-Tab in the Admin-Interface. This means by simply adding a article-category and publishing at least one article in it a user can add a “Page” to the Website.

The TXP- Tag:

<txp:zoo_section_and_category_list>

Parameters

Same as section_list but with a few more:

  • showall : Can be set to either 0 or 1. With this set to 1 the 2nd Level (categories) is always shown. 0 shows 2nd Level for active section only.
  • cat_active_class : Put in css-class for the active category-link
  • cat_class : Put in css-class for the inactive category-links

Example Usage:

Assuming you have four Sections – “Companyportrait,Products,Partner,Products” and have published several Articles in the section “Products” – each in one of the Categories “Concept,Productcategory1 and Productcategory2”.
The following tag

<zoo_section_and_category_list wraptag=“span” active_class=“menue_links_on” class=“menue_links_off” cat_class=“cat_links_off small” cat_active_class=“cat_links_on small” include_default=“0” showall=“0” sections=“Companyportrait,Products,Partner,Contact” />

produces:

<span class=“menue_links_off”> <a href=“http://dev.test.com/Companyportrait/”>Companyportrait</a><br /> <a class=“menue_links_on” href=“http://dev.test.com/Products/”>Products</a><br /> <a class=“cat_links_off small” href=“http://dev.test.com/Products/?c=Concept”>Concept</a><br /> <a class=“cat_links_on small” href=“http://dev.test.com/Products/?c=Productcategory1”>Productcategory1</a><br /> <a class=“cat_links_off small” href=“http://dev.test.com/Products/?c=Productcategory2”>Productcategory2</a><br /> <a href=“http://dev.test.com/Partner/”>Partner</a><br /> <a href=“http://dev.test.com/Contact/”>Contact</a>
</span>

Example CSS:

.menue_links_off, .cat_links_off{
text-decoration: none;
color: #000;
border: none;}
.menue_links_on, .cat_links_on{
text-decoration: none;
color: #A80017;
border: none;}

Last edited by arnski (2007-11-17 00:44:51)

Offline

#9 2007-08-23 16:38:28

arnski
Archived Plugin Author
From: Hamburg, Germany
Registered: 2007-08-21
Posts: 21
Website

Re: Adaptable 2-Level Navigation-Menu with Highlighting

Helpfull comments, as well as psycotic rants about my coding style a.s.f. are welcome.. ()

Offline

#10 2007-08-23 16:50:42

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Adaptable 2-Level Navigation-Menu with Highlighting

You may want to register your plugin prefix, create a new topic about this plugin in the plugins subforum and add it on textpattern.org as well.

Offline

#11 2007-08-24 08:34:03

arnski
Archived Plugin Author
From: Hamburg, Germany
Registered: 2007-08-21
Posts: 21
Website

Re: Adaptable 2-Level Navigation-Menu with Highlighting

well ..

  • i tried to log in to the textbook wiki to register my plugin prefix but keep getting an internal server error?
  • i created a new topic in the plugins section
  • textpattern.org is next on my list

thx 8)

Offline

#12 2007-08-24 08:36:12

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: Adaptable 2-Level Navigation-Menu with Highlighting

Do you have this in action anywhere to see?

Offline

Board footer

Powered by FluxBB