Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Generating a HTML site map
Hey John,
This does exactly that for me:
in the page template (or wherever suits your site)
<ul>
<txp:article_custom limit=99999 form="my_sitemap" sortby="-custom_1" section="section-1, section-2, section-3"/>
</ul>
and in the form my_sitemap
<txp:if_different>
<h3><txp:section title=1 link=1 /></h3>
</txp:if_different>
<li><txp:permlink><txp:title /></txp:permlink></li>
I added the section-1, section-2, section-3 because I don’t want section-4 appearing in the site map. I sorted by the ‘-’ value in custom field 1 which I had already used to get the articles in the correct order in my main navigation and so now again in the site map.
Last edited by joebaich (2008-09-16 12:12:52)
Offline
Re: Generating a HTML site map
Wow, Joe. Thanks again!
Offline
Re: Generating a HTML site map
Sorry John, I didn’t realise you had already been to that resource — thanks for the explanation.
And thanks Joe – that looks like it might help me too!
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#19 2008-09-16 15:05:43
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Generating a HTML site map
joebaich wrote:
This does exactly that for me:
OK, that works, but does the <h3> belong inside a list? ;) What would be perfect – and what is not (yet) possible with if_different – is nested lists.
Offline
Re: Generating a HTML site map
Oo? I keep getting sections split up (Section, articles, Other section and articles then the first section again with remaining articles).
Oh well — ran out of time and for now have had to hard code (yuk).
But. Did wonder if it might be good to use DL in the page and DT and DDs in the form, this would solve the H3 inside a UL.
Wish I had time to explain that better, sorry not done so, will do again another time if not self-explanatory (but sure it is). Hope this thought is helpful.
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#21 2008-09-16 22:06:05
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Generating a HTML site map
alanfluff wrote:
Oo? I keep getting sections split up (Section, articles, Other section and articles then the first section again with remaining articles).
You need to sort by section in the article tag.
Offline
Re: Generating a HTML site map
Thanks Els!
When I try this next site, I’ll see how the DL approach pans out too — I don’t think it’s a misuse of an HTML tag – still semantic (I think).
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
Re: Generating a HTML site map
Els,
You are absolutely right, h3 does look out of place in a UL and likely won’t validate. I think alanfluff is on a surer footing with the DL and that it likely will validate. I originally did the site map as an exercise on a live site but the client wasn’t sold on the idea of having one at all, so I moved on before dotting the i’s and crossing the t’s. I speak a bit of dog too, by the way.
Alan,
Can’t comment without seeing the code you tried other than to recall that sorting on a value in custom_1 in <txp:article_custom/> seemed to be the key for me, I didn’t spend much time with sorting on sections because I needed the site map entries to appear in the same order as the main navigation. I used values like 100-199 for section-1, 200-299 for section_2 and so on to get the articles’ titles in the desired order in the main navigation which was based on a DL with a similar construction to the site-map. I will revisit the site map to see if I can adapt it to use the DL.
Last edited by joebaich (2008-09-17 03:48:16)
Offline
Re: Generating a HTML site map
Using definition lists could validate, but I wouldn’t call it semantic. Semantics is meaning, and dl means “definition list.” Calling the names of articles in a section definitions of the section name is a bit of a stretch.
Using header elements is more semantically correct even if they’re improperly nested.
Offline
Re: Generating a HTML site map
John,
Using definition lists could validate, but I wouldn’t call it semantic.
Dunno, using a list of article titles as definition descriptions [dd] to define the content of a Section, the title of which is expressed as a definition term [dt] seems reasonably semantic to me. How better to describe a section than to state succinctly what it contains? It’s all semantics isn’t it :-)!
Anyway,
<dl>
<txp:article_custom limit=99999 form="my_sitemap" sortby="-custom_1" section="section-1, section-2, section-3"/>
</dl>
and in the form my_sitemap
<txp:if_different>
<strong><dt><txp:section title=1 link=1 /></dt></strong>
</txp:if_different>
<dd><txp:permlink><txp:title /></txp:permlink></dd>
worked well for me; see below. It needs some styling and the inline quick and dirty <strong> tab removed but illustrates the point.

Last edited by joebaich (2008-09-17 04:34:59)
Offline
Re: Generating a HTML site map
Joe
…sorting on a value in custom_1 in <txp:article_custom/> seemed to be the key for me…
Thanks Joe — I’ll check this next time.
John/Joe
Glad re: DL – I admit to a weakness for DL, I like to use it more rather than less liberally but hopefully I have not strayed too far outside it’s meaning (yet!). Cheers!
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#27 2008-09-17 17:09:12
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Generating a HTML site map
johnstephens wrote:
Using definition lists could validate, but I wouldn’t call it semantic. Semantics is meaning, and
dlmeans “definition list.” Calling the names of articles in a section definitions of the section name is a bit of a stretch.Using header elements is more semantically correct even if they’re improperly nested.
Interesting discussion. Does ‘semantically correct but invalid html’ precede ‘valid html but semantically incorrect’ or vice versa? Seriously, I’d like to know.
joebaich wrote:
I speak a bit of dog too, by the way.
(OT) My Dog is ‘read only’, but that’s not a problem since most dogs are very good at ‘read only’ Human :)
Offline
Re: Generating a HTML site map
…Interesting discussion. Does ‘semantically correct but invalid html’ precede ‘valid html but semantically incorrect’ or vice versa? Seriously, I’d like to know…
Els — I would be unhappy with either, but if I was told to go live on a desert island with only one or the other, the one I could get on best with is invalid HTML that is semantically correct because there I am ‘hurting’ the rules, the BOTS, etc, but I am passing the human reader more meaning, and that seems the top priority of content. Of course in the real world the human reader might not get to read it as my malformed HTML might cause too many other well formed web pages to be seen before mine in search engines, so I would become invisible.
I still have to say that I agree with Joe that this is not a case of ‘wrong’ use of DL (DT, DD), but I accept that if one is looking for perfect examples of DL usage, then perhaps this is not the best (nod to John’s comments). But compromise is so often necessary, and if it’s made with care then all should remain well.
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#29 2008-09-17 17:35:50
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Generating a HTML site map
Alan, thanks for your view. I tend to agree on this
because there I am ‘hurting’ the rules, the BOTS, etc, but I am passing the human reader more meaning, and that seems the top priority of content.
but I’m not so sure if in this case you are really ‘passing the human reader more meaning’: human readers hardly ever look at markup, do they?
Offline
Re: Generating a HTML site map
…but I’m not so sure if in this case you are really ‘passing the human reader more meaning’: human readers hardly ever look at markup, do they?…
Yes, I agree completely.
However, I always think, when considering if I am passing on meaning, of the web page with all CSS turned off so the reader sees the content as it is meant to be rendered by the most basic rules (those built into the browser).
So in this case, assuming an H3 inside a UL would mis-align (guessing it would, not tested), and knowing how a DL would look, I believe more/clearer meaning would be transferred to the reader. Admittedly my imaginary reader in this case is either someone who has turned off CSS or any CSS present is not visually doing the opposite of the browsers built in rules for these tags.
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline