Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2005-10-18 21:15:47

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: static site with dynamic two-level nav

<blockquote><p>kalius wrote:
Your method is good, but I believe the main advantage for using a CMS and templates is not to have to hardcode everything, Adding a section or changing a section name will make me edit all templates and conditionals, etc.</p>
<p>Sencer wrote:
Hence why nardo wrote a post on dynamic two-level nav, where dynamic means less manual fiddling. </p>
</blockquote>

Thanks for replying, but excuse me kalius and sencer:

Where did I suggest something made manually or hardcoded?
are you talking about this lines?
<div style=“font-size:85%;”>
<pre>
&lt;txp:mdn_if_section section=“about-us”&gt;
&lt;ul id=“sub-nav”&gt; &lt;!—some hardcoded subnav or content —&gt; &lt;li>&lt;a href=”“&gt;me&lt;/a&gt;&lt;/li&gt; &lt;li>&lt;a href=”“&gt;he&lt;/a&gt;&lt;/li&gt; &lt;li>&lt;a href=”“&gt;she&lt;/a>&lt;/li&gt;
&lt;/ul&gt;
&lt;/txp:mdn_if_section>
</pre></div>

I put that just as an example more related to the use of “mdn_if_section”, showing that you dont need to use the sub-nav <strong>dinamically created</strong> everywhere.
I would delete that chunk right now, because I think it is confusing.

If isnt that, <strong>I cant see the “menu manually hardcoded” part of my solution</strong> (or are you talking about ako_nav hardcoded menu? <span style=“color:red;”>see comments below in this post</span>).

<strong>“Deep” explanation:</strong>

My solution is based in nardo’s proposed solution.
I think nardo’s proposed solution is a good one. In fact, I based my solution in nardo’s work.

First: <strong>my step 4.A achieves the same results that nardo’s solution</strong>.
They are very similar yet not the same. For output the subnav, mine uses an built-in TXP tag (<code>txp:article</code>), and <code>mdn_if_section </code>can also be replaced by a built-in TXP tag.
Another possible advantage: mine uses “sticky” articles, that is <strong>more semantically meaningful</strong> to the goal of achieve an static page.

But <strong>nardo’s solution</strong> is very general, and I think it has some limitation:
  • What will you do (following nardo’s method) if you want a different (or none) navigation in a section that has articles?
  • nardo’s method needs a “negative” condition (to not be the “default” page) to output the nav. He use and empty conditional to display nothing if you are in default section. is that a clean approach?. (<span style=“color:red;”>note: mine 4A step method uses this “negative” condition method too</span>)
  • What about doing different types of sub-nav? not just sub-nav list pulled from articles titles, but list of categories or others?
  • needs
<strong>My solution</strong>:
  • <strong>can be achieved with built-in TXP tags</strong> (<span style=“color:red;”>or am I wrong?</span>)
  • it has two methods: one short and general (step 4A) and one long and powerful (step 4B)
  • lets you <strong>dinamically</strong> generate subnavs:
    • in the sections you need, with two methods:
      • short and “negative” method : “if this is not section ‘default’ output my subnav” (same subnav to all not-default sections)
      • long and “negative” method : “if this is section ‘YYY’ output my subnav” (customized subnav for that YYY section)
    • only if you need it
    • using different types of subnav
    • you use just one page template (‘default’) and manage the sections by using mdn_if_section plug-in
    • you dont need chh_article_custom plugin, and dont need to hack it.
    • that <strong>can be made with built-in TXP tags</strong>, without needing of modding a plug-in
<strong>Comments</strong>:
  1. both solutions (nardo and mine) have a <strong>manually hardcoded</strong> element: <strong>the ako_nav generated menu is, from my point of view, a hardcoded menu in a nice way</strong>. I mean, it doesnt generate the menu items from the sections in the database. It’s just a menu hardcoded in a plug-in tag, but it’s cool, because TXP has some limitation when generating section menus. (ok, I should wait for 4.0.2+ for <a href=“http://textpattern.com/weblog/91/improved-section-and-category-nav-tags”>new improvements on this</a>)
  2. maybe that is what you considered as “menu manually hardcoded”?

So, Sencer, kalius, I would appreciate if you can read and follow my solution and give me new feedback, and please, correct me if I’m wrong.

I dont want to sound rude, buy my english isnt the best and I dont want to hijack this thread in a “mine is bigger and better than yours”.

BTW, nardo’s work is great and is a similar approach… and with nardo, we share similar feelings about Drupal… . ¡Te amo, nardo! ¡horses for courses!

Last edited by maniqui (2005-10-18 21:54:55)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#14 2005-10-18 21:50:06

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: static site with dynamic two-level nav

What I meant is that you replaced:

<code>
<ul id=“sub-nav”>
<txp:chh_article_custom listform=“nav-level-2” />
</ul>
</code>

with (just with different section names each time):
<code>
<txp:mdn_if_section section=“training-courses”> <ul id=“sub-nav”> <txp:article_custom section=“training-courses”“ status=“sticky” form=“nav-level-2”
sortby=“custom_1” sortdir=“asc” /> <!—dinamically generated items—> </ul>
</txp:mdn_if_section>
<txp:mdn_if_section section=“training-courses”> <ul id=“sub-nav”> <txp:article_custom section=“training-courses”“ status=“sticky” form=“nav-level-2”
sortby=“custom_1” sortdir=“asc” /> <!—dinamically generated items—> </ul>
</txp:mdn_if_section>
<txp:mdn_if_section section=“training-courses”> <ul id=“sub-nav”> <txp:article_custom section=“training-courses”“ status=“sticky” form=“nav-level-2”
sortby=“custom_1” sortdir=“asc” /> <!—dinamically generated items—> </ul>
</txp:mdn_if_section>
<txp:mdn_if_section section=“training-courses”> <ul id=“sub-nav”> <txp:article_custom section=“training-courses”“ status=“sticky” form=“nav-level-2”
sortby=“custom_1” sortdir=“asc” /> <!—dinamically generated items—> </ul>
</txp:mdn_if_section>
(… repeat for as many sections as there are …)
</code>

This means a lot of repetition. And yes, having to manually repeat it everytime allows you to make changes for each item.
I am not saying it is bad, just that for the common case, nardo’s solution is shorter and easier to maintain changes with, IMHO.

Offline

#15 2005-10-18 22:27:02

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: static site with dynamic two-level nav

Sencer, ok, you are talking about the method in step 4B. This is the long and powerful method, because it lets you add or not a different subnav or nothing in each section, if you want, and <strong>BTW you dont have to “repeat for as many sections as there are” as you said</strong>. If you dont want subnav in a particular section, just dont put a conditional if_section for that one).

Now, is there any difference (aside the tag/plug-ins implied) between nardo’s method and the followings?

Solution 4A (with a plug-in and a TXP built-in tag):
<div style=“font-size:85%;”>
<pre>
&lt;txp:mdn_if_section notsection=“default”&gt; &lt;ul id=“sub-nav”&gt; &lt;txp:article status=“sticky” form=“nav-level-2” sortby=“custom_1” sortdir=“asc” /&gt; &lt;/ul&gt;
&lt;/txp:mdn_if_section&gt;
</pre></div>

Solution 4A.bis (<strong>doesnt need plug-ins</strong> and use two TXP built-in tags, and using meaningful “sticky” articles):
<div style=“font-size:85%;”>
<pre>
&lt;txp:if_section name=”“&gt; &lt;!— use name=”“ for default section —&gt;
&lt;txp:else /&gt; &lt;ul id=“sub-nav”&gt; &lt;txp:article status=“sticky” form=“nav-level-2” sortby=“custom_1” sortdir=“asc” /&gt; &lt;/ul&gt;
&lt;/txp:if_section&gt;
</pre></div>

That one also can grow up if you use if_section per each section you have conditional content.

<strong style=“color:red;”>Edit: none of the above solutions seems to work, because in an individual article page, you dont get the full article list in the subnav.</strong>

¿Comments?

<hr />
<strong>The step 4B method (“the long and powerful”)</strong>

<div style=“font-size:85%;”>
<pre>
[…ako_nav stuff]
&lt;txp:mdn_if_section section=“services”&gt; &lt;ul id=“sub-nav”&gt; &lt;txp:article_custom section=“services” status=“sticky” form=“nav-level-2” sortby=“custom_1” sortdir=“asc” /&gt; &lt;/ul&gt;
&lt;/txp:mdn_if_section&gt;
[…more mdn_if_section_stuff]
</pre></div>

<del>There is no need of <code><txp:article_custom section=“section_name”… /></code>, because if you are parsing and if_section tag is because you are in a section context, so <code><txp:article /></code> is enough.</del>
<ins>Sorry. This was a big mistake by me: <strong> if you dont use <code><txp:article_custom /></code>, you wont get the full article list in the subnav in an individual article page.</strong></ins>

Last edited by maniqui (2005-10-19 04:53:46)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#16 2005-10-19 04:48:35

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: static site with dynamic two-level nav

I must apologizes.
I think I went totally wrong with some of my approaches, specialy with the “short” one (the step 4A).

I must becoming crazy, because I though I tested that on individual article pages…
But now, with that first approach, I cant get to display, in an individual article page, the full article list in the subnav

The method in step 4B works.

I deleted some lines in my previous posts, lines with code that doesnt work (but I intentionally left some code that also doesnt work, as example of the mistakes I made, and to keep the thread comprensible).
BTW: to edit/delete concept/code errors in posts is this a practice that must be avoided at all?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#17 2006-11-27 15:13:37

treb0r
Member
From: Hebden Bridge, UK
Registered: 2005-09-05
Posts: 20
Website

Re: static site with dynamic two-level nav

Hey All,

I’ve got nardo’s two level nav working as per the first post in this thread. I would like to learn how it is possible to style the title of the active article in the subnav, like ako_nav does automatically in the first level.

Thanks in advance!

Offline

Board footer

Powered by FluxBB