Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-05-12 14:54:57

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

section landing page

Hi,
How can I make a section’s default landing page contain one specific article and not a list of all the articles in that section?

For instance I would like this page
http://nwtc.ie/index.php?c=training

to be like this one.
http://nwtc.ie/index.php?id=7

The second link uses the same page template but i dont see how to format the default landing page for a section

please advise

Last edited by kvnmcwebn (2007-05-12 15:50:10)


its a bad hen that wont scratch itself.
photogallery

Offline

#2 2007-05-12 19:23:50

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: section landing page

hey, so the first link you provided is the landing page for the category “training”. I would suggest putting an if_category tag in your page. This way you can catch if the category is training and you can define what should be shown.

Offline

#3 2007-05-12 21:47:08

NeilA
Member
From: Blue Mountains, Australia
Registered: 2004-08-15
Posts: 316
Website

Re: section landing page

Or you can use a section-specific ‘sticky’ article.


Neil – Blue Mountains, Australia

http://westserve.org
http://ministrygrounds.net.au

Offline

#4 2007-05-12 21:59:41

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: section landing page

If you just want only the last article to show use <txp:article limit="1" ... />, which will show only one article. If you want to always show the same article with a specific ID, use <txp:article_custom id="(article-id-number)" ... />. Put that inside an txp:if_category tag like variaas suggests, e.g.:

<txp:if_category name="training">
<txp:article_custom id="7" form="myform" />
<txp:else />
...
</txp:if_category>

etc.


TXP Builders – finely-crafted code, design and txp

Offline

#5 2007-05-12 23:38:17

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: section landing page

thanks this is brilliant, can you just bare with me for a minute.
I will create a custom article for the landing page and give it a custom article id right.
But whats form for?

<txp:if_category name=“training”>
<txp:article_custom id=“7” form=“myform” />
<txp:else />

<txp:article allowoverride=“0” pgonly=“0” searchall=“1” searchsticky=“0” sort=“Category1 asc” status=“4” />
</txp:if_category>

Neil I will have to look up the “sticky” article, does that mean the article persists in the article listing order?


its a bad hen that wont scratch itself.
photogallery

Offline

#6 2007-05-13 00:38:42

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: section landing page

form is the name of the article form you use to display your articles. If you don’t specify it, the standard form “default” will be used (you can look it up in the forms tab).
You don’t need to create a custom article or id, just note the ID number of the article you want to show up on the training category page and use it in place of “7” in the example above (the ‘custom’ refers only to the function which offers more customised article output compared to the standard txp:article, both use the normal articles).


TXP Builders – finely-crafted code, design and txp

Offline

#7 2007-05-13 07:39:13

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: section landing page

wow this is really helpful


its a bad hen that wont scratch itself.
photogallery

Offline

#8 2007-05-13 12:35:42

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: section landing page

Ok got this working, i had to change the if_category to an if_section.
<txp:if_section name=“training”>
<txp:article_custom id=“10” form=“default” />
<txp:else />
<txp:article form=“default” limit=“1” />

</txp:if_section>

It works fine. but what should i put in for the <else>? i cant seem to get any of the other articles to work with the above code. it returns this error

Notice: missing_article_tag: training in /home/nwtc/www/textpattern/publish.php on line 462

heres the link
http://nwtc.ie/index.php?s=training

Last edited by kvnmcwebn (2007-05-13 12:49:08)


its a bad hen that wont scratch itself.
photogallery

Offline

#9 2007-05-14 00:27:31

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

Re: section landing page

Try the following (comments added so you can see what each does):

<!-- if we are on the "training" section... -->
<txp:if_section name="training">

	<!-- if we are viewing an individual article... -->
	<txp:if_individual_article>

		<!-- ...display it -->
		<txp:article limit="1" />

	<!-- otherwise... -->
	<txp:else />

		<!-- ...display a specific article -->
		<txp:article_custom id="10" />

	</txp:if_individual_article>

<!-- otherwise... -->
<txp:else />

	<!-- ...show 1 article at a time -->
	<txp:article limit="1" />

</txp:if_section>

You will still get that notice, but you can safely ignore it. Changing your “Production mode” in your Preferences to “Live” will hide it from view.

Offline

#10 2007-05-14 10:52:47

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: section landing page

Mary this is magic, it works beautifully.
You’ve saved me from hacking this site together…i was just about to get out the duct tape.
It never would have occurred to me to nest conditional comments.
thanksX10


its a bad hen that wont scratch itself.
photogallery

Offline

Board footer

Powered by FluxBB