Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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>
<txp:mdn_if_section section=“about-us”>
<ul id=“sub-nav”> <!—some hardcoded subnav or content —>
<li><a href=”“>me</a></li>
<li><a href=”“>he</a></li>
<li><a href=”“>she</a></li>
</ul>
</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.
- 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>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
- in the sections you need, with two methods:
- 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>)
- 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)
Offline
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
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>
<txp:mdn_if_section notsection=“default”>
<ul id=“sub-nav”>
<txp:article status=“sticky” form=“nav-level-2” sortby=“custom_1” sortdir=“asc” />
</ul>
</txp:mdn_if_section>
</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>
<txp:if_section name=”“> <!— use name=”“ for default section —>
<txp:else />
<ul id=“sub-nav”>
<txp:article status=“sticky” form=“nav-level-2” sortby=“custom_1” sortdir=“asc” />
</ul>
</txp:if_section>
</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]
<txp:mdn_if_section section=“services”>
<ul id=“sub-nav”>
<txp:article_custom section=“services” status=“sticky” form=“nav-level-2” sortby=“custom_1” sortdir=“asc” />
</ul>
</txp:mdn_if_section>
[…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)
Offline
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?
Offline
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