Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Navigation > txp:if_section and txp:if_category > What do I do wrong?
“Hej and hello everybody!”
I’m having some trouble with constructing a navigation for my project. Here is what i got:
<div id="header">
<ul>
<li <txp:if_section name="section1">id="current"</txp:if_section>><txp:section link="1" title="1" name="section1"></li>
<li <txp:if_section name="section2">id="current"</txp:if_section>><txp:section link="1" title="1" name="section2"></li>
<li <txp:if_section name=",section3">id="current"</txp:if_section>><txp:section link="1" title="1" name="section3"></li>
</ul>
</div>
Followd by this:
<txp:if_section name="section1">
<div id="subnav">
<ul>
<li <txp:if_category name="category1">id="active"</txp:if_category>><txp:category name="category1" title="1" link="1" /></li>
<li <txp:if_category name="category2">id="active"</txp:if_category>><txp:category name="category2" title="1" link="1" /></li>
<li <txp:if_category name="category3">id="active"</txp:if_category>><txp:category name="category3" title="1" link="1" /></li>
<li <txp:if_category name="category4">id="active"</txp:if_category>><txp:category name="category4" title="1" link="1" /></li>
</ul>
</div>
</txp:if_section>
And the output mixes them up as far as i can tell:
<div id="header">
<ul>
<li ></li>
<li ><a href="http://127.0.0.1/Category/Category2/">Category2</a></li>
<li ><a href="http://127.0.0.1/Category/Category3/">Category3</a></li>
<li ><a href="http://127.0.0.1/Category/Category4/">Category4</a></li>
</ul>
</div>
Sorry some error in this, manual edit. (header and manbar/manav)
Last edited by theLostShirt (2008-02-03 00:31:25)
Offline
#2 2008-02-02 23:32:59
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Navigation > txp:if_section and txp:if_category > What do I do wrong?
You’re not trying to tell me that TXP is changing div id="subnav"
into div id="header"
are you??? ;)
I assume this output is on the ‘section1’ page? It’s hard to tell what is going wrong without a tag trace.
Offline
Re: Navigation > txp:if_section and txp:if_category > What do I do wrong?
This is what i got striping everything out besides the navigation.
The input:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><txp:page_title /></title>
</head>
<body>
<!-- head + mannav -->
<div id="header">
<ul>
<li <txp:if_section name="section3">id="current"</txp:if_section>><txp:section link="1" title="1" name="section3"></li>
<li <txp:if_section name="section2">id="current"</txp:if_section>><txp:section link="1" title="1" name="section2"></li>
<li <txp:if_section name=",section1">id="current"</txp:if_section>><txp:section link="1" title="1" name="section1"></li>
</ul>
</div>
<txp:if_section name="section3">
<!-- Subnav section3 -->
<div id="subnav">
<ul>
<li <txp:if_category name="cat1">id="active"</txp:if_category>><txp:category name="cat1" title="1" link="1" /></li>
<li <txp:if_category name="cat2">id="active"</txp:if_category>><txp:category name="cat2" title="1" link="1" /></li>
<li <txp:if_category name="cat3">id="active"</txp:if_category>><txp:category name="cat3" title="1" link="1" /></li>
<li <txp:if_category name="cat4">id="active"</txp:if_category>><txp:category name="cat4" title="1" link="1" /></li>
</ul>
</div>
</txp:if_section>
</body>
</html>
The output:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tranberry Jobb</title>
</head>
<body>
<!-- head + mannav -->
<div id="header">
<ul>
<li></li>
<li><a href="http://127.0.0.1/textpattern/kategori/cat2/">cat2</a></li>
<li><a href="http://127.0.0.1/textpattern/kategori/cat3/">cat3</a></li>
<li><a href="http://127.0.0.1/textpattern/kategori/cat4/">cat4</a></li>
</ul>
</div>
</txp:if_section>
</body>
</html>
<!-- Runtime: 0,0717 -->
<!-- Query time: 0,002494 -->
<!-- Queries: 11 -->
<!-- Memory: no info available -->
<!-- txp tag trace:
[SQL (0,000865): select name from txp_lang where lang='sv-se' limit 1]
[SQL (0,024472): select name, data from txp_lang where lang='sv-se' AND ( event='public' OR event='common')]
[SQL (0,001690): select name, code, version from txp_plugin where status = 1]
[SQL (0,000545): select * from txp_section where name = 'default' limit 1]
[SQL (0,000376): select host from txp_log where ip='127.0.0.1' limit 1]
[SQL (0,000331): select user_html from txp_page where name='default']
[Sida: default]
<txp:page_title/>
<txp:if_section name="section3">
[<txp:if_section name="section3">: false]
</txp:if_section>
<txp:section link="1" title="1" name="section3"></li>
<li <txp:if_section name="section2">id="current"</txp:if_section>><txp:section link="1" title="1" name="section2"></li>
<li <txp:if_section name=",section1">id="current"</txp:if_section>><txp:section link="1" title="1" name="section1"></li>
</ul>
</div>
<txp:if_section name="section3">
<!-- Subnav section3 -->
<div id="subnav">
<ul>
<li <txp:if_category name="cat1">id="active"</txp:if_category>><txp:category name="cat1" title="1" link="1" />
[SQL (0,000381): select title from txp_section where name='cat1'] <txp:if_category name="cat2">
[<txp:if_category name="cat2">: false] </txp:if_category>
<txp:category name="cat2" title="1" link="1" />
[SQL (0,000393): select title from txp_category where name='cat2' and type='article'] <txp:if_category name="cat3">
[<txp:if_category name="cat3">: false] </txp:if_category>
<txp:category name="cat3" title="1" link="1" />
[SQL (0,000375): select title from txp_category where name='cat3' and type='article'] <txp:if_category name="cat4">
[<txp:if_category name="cat4">: false] </txp:if_category>
<txp:category name="cat4" title="1" link="1" />
[SQL (0,000374): select title from txp_category where name='cat4' and type='article']
[ ~~~ secondpass ~~~ ]
-->
This is all on the firstpage
Last edited by theLostShirt (2008-02-03 00:33:51)
Offline
Re: Navigation > txp:if_section and txp:if_category > What do I do wrong?
To avoid bugs in some old browsers, it would better to use:
<li<txp:if_section name="section1"> id="current"</txp:if_section>><txp:section link="1" title="1" name="section1"></li>
For avoiding the extra space :)
Are you sure that section3
exist? As the navigation is inside <txp:if_section name="section3">
it would only be shown on section3.
Also some tags ie. <txp:section link="1" title="1" name="section1">
miss their ending slash as far i can tell. But you edited that tagtrace, didn’t you? If you didn’t, there is also one extra <txp:if_section name="section3">
with out ending tag.
Last edited by Gocom (2008-02-03 00:39:12)
Offline
Re: Navigation > txp:if_section and txp:if_category > What do I do wrong?
Gocom wrote: To avoid bugs in some old browsers, it would better to use:
<li<txp:if_section name=“section1”> id=“current”</txp:if_section>><txp:section link=“1” title=“1” name=“section1”></li>
For avoiding the extra space :)
Thanks for the info, I added the extra space to test if TXP did recognise the “txp:if_section” tag.
Offline
Re: Navigation > txp:if_section and txp:if_category > What do I do wrong?
Thanks Gocom for that ending slash!
It was indeed a silly error of me, I’m a but rusty it seems. I believe that will solve my problem, going to check that now.
Offline
#7 2008-02-03 01:37:48
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Navigation > txp:if_section and txp:if_category > What do I do wrong?
Gocom wrote:
If you didn’t, there is also one extra
<txp:if_section name="section3">
with out ending tag.
I don’t see that in the code? But in the html output I do see a stray closing tag:
<body>
<!-- head + mannav -->
<div id="header">
<ul>
<li></li>
<li><a href="http://127.0.0.1/textpattern/kategori/cat2/">cat2</a></li>
<li><a href="http://127.0.0.1/textpattern/kategori/cat3/">cat3</a></li>
<li><a href="http://127.0.0.1/textpattern/kategori/cat4/">cat4</a></li>
</ul>
</div>
</txp:if_section> <!-- HERE -->
</body>
Offline
Offline