Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-23 14:28:59

benb
New Member
Registered: 2004-03-06
Posts: 4

...display the Title of the First Article within the Body of the Page

Hi Guys

I’m using TXP as a CMS. I have articles set as “sticky” then other articles from that section all displayed on one page. Rather than setting up a new page for each section and hard-code the title, I’d like to use the Title of the first Article, within the title of the page.

I know all the data is there, it’s just a question of chaining these bits marked info together. This is where I am right now…

  • Request URL with section name (let’s call it ‘shoes’)
  • Textpattern finds a generic page template for the section ( info $thispage[‘s’] ) then works through the template
  • Template asks for articles in this ‘shoes’ section ( info <txp:article form="static_article" status="sticky" /> )
  • Single article is returned and I can get the title from that ( info $thisarticle[‘title’] )

I’d like to chain these together, so that within the Page template and outside an article, I can get hold of that bit of data. Not worried whether that happens through a plugin, raw php or some clever use of txp tags.

I’ve looked at <txp:if_section /> but that would mean adding an entry to the code for each change of title; and I’m keen to pull as much data as possible from the exisiting content, and have the page title updated if the article title is updated.

Any help with this appreciated.

Regards

Ben

Offline

#2 2005-11-23 14:58:28

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

Re: ...display the Title of the First Article within the Body of the Page

I think you could do something like this:
<code>
<txp:if_section>
<txp:article status=“sticky” form=“title” limit=“1” />
</txp:if_section>
</code>
where your form “title” contains the article title.

The way I expect this to behave is that the article tag will show the title of the sticky article in the section you are viewing. If there is more than one sticky article in a section, you can use the sortby attribute to show the latest one.

You also might find a use in the if_first_article and/or if_last_article tags.

Offline

#3 2005-11-23 19:12:06

benb
New Member
Registered: 2004-03-06
Posts: 4

Re: ...display the Title of the First Article within the Body of the Page

Els

That is a truly excellent and elegant solution. I removed the <if_section> tags and it works a treat.

Thanks

Ben

Offline

Board footer

Powered by FluxBB