Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-01-12 17:09:27

bauhouse
Archived Plugin Author
From: Abbotsford, BC Canada
Registered: 2004-06-29
Posts: 68
Website

[howto] Sort articles in dynamically generated list and display active article

After I posted a site in Let’s See Yours, soulship thought I should add this example here, so here is a method I developed using only the core tags to sort articles in a dynamically generated list and display the active article.

This is accomplished by using a custom field named “sort” with the following code in the page template:
<code>
<div id=“sectionNav”>
<h2><txp:section title=“1” link=“1” /></h2>
<ul class=“article<txp:article limit=“1” form=“custom_sort” sortby=“custom_1” sortdir=“asc” />”>
<txp:article_custom section=“news” form=“list” sortby=“custom_1” sortdir=“asc” />
</ul>
</div><!— END sectionNav —>
</code>

The “custom_sort” form is an article form with the following code:
<code><txp:custom_field name=“sort” /></code>

The “list” form is an article form with the following code:
<code><li class=“menu<txp:custom_field name=“sort” />”><txp:permlink><txp:title /></txp:permlink></li></code>

Then, in the CSS, I just need to use the following code:
<code>#sectionNav ul.article01 li.menu01 a, #sectionNav ul.article02 li.menu02 a, #sectionNav ul.article03 li.menu03 a, #sectionNav ul.article04 li.menu04 a, #sectionNav ul.article05 li.menu05 a, #sectionNav ul.article06 li.menu06 a, #sectionNav ul.article07 li.menu07 a, #sectionNav ul.article08 li.menu08 a {
color:#900;
background:url(i/sectionmenu_active.jpg) right top repeat-y;
}</code>

If it was possible to set txp:article_custom to recognize the current section, I could develop most of the site in this manner using one page template. For now, this is possible, as nardo noted, by using the chh_article_custom plugin.

Offline

#2 2006-06-02 18:44:05

Ace of Dubs
Member
Registered: 2006-04-17
Posts: 446

Re: [howto] Sort articles in dynamically generated list and display active article

Wow…really nice job here, original design, tight TXP coding, and for a worthy cause as well..kudos!

Just one little nitpick. Is there a way you can program the href titles to display custom text, instead of “permanent link to this article”?

Curious

Offline

#3 2006-06-02 18:49:18

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [howto] Sort articles in dynamically generated list and display active article

Ace of Dubs wrote:

Is there a way you can program the href titles to display custom text, instead of “permanent link to this article”?

You can change that in the txp_lang table, or in the language file and then re-install it. Or have a look at zem_link, that even lets you display the article title as href title.

Offline

#4 2006-06-02 19:07:38

Ace of Dubs
Member
Registered: 2006-04-17
Posts: 446

Re: [howto] Sort articles in dynamically generated list and display active article

Downloading zemlink now…

Cheers Els!

ps – nice dog

Offline

#5 2006-06-03 04:40:38

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [howto] Sort articles in dynamically generated list and display active article

Or you can do: <a href="<txp:permlink />" title="whatever the hell you want">link</a>. :)

Offline

#6 2006-06-03 17:24:53

Ace of Dubs
Member
Registered: 2006-04-17
Posts: 446

Re: [howto] Sort articles in dynamically generated list and display active article

Thanks Mary… your zen-like advice is always appreciated :)

btw..what happened to SpongeBob? The new look is a little … umm…yeah

Offline

Board footer

Powered by FluxBB