Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-06-04 18:34:01
- brianlux0r
- Member
- Registered: 2007-06-04
- Posts: 41
[howto] best way to control front page content
What is best method of controlling front page content, for example if I want 1 article to be used only for bulk of front page content?
Offline
#2 2007-06-04 19:54:57
- FireFusion
- Member
- Registered: 2005-05-10
- Posts: 698
Re: [howto] best way to control front page content
Create a new section called “homepage”. Make sure it is the only section set with the setting “On front page?” set. Post one article in it and that’s what will appear on the homepage.
If you mean not displaying a list of articles on all section homepages then use this code.
<txp:if_article_list>
<txp:article limit="1" status="sticky" />
<txp:else/>
<txp:article />
</txp:if_article_list>
Make sure you have one article in each section set to “sticky” and that will be the homepage for that section.
Offline
Re: [howto] best way to control front page content
Hi, one could interpret your question in different ways
- If you mean you want to see a single most-recent article, then use txp:article or txp:article_custom with the attribute
limit="1"
. - If you want to change the front page articles every now and then, try using
txp:article(_custom)
with the attributestatus="sticky"
. Then you or the site admin need only set the status of particular articles to “sticky” to make them appear on the front page. - If you want a static but user-editable article to appear on the front page (e.g. a standard intro text), you can use
txp:article_custom id="123" form="myform" status="whatever"
. You don’t need status, but if it is an article that you don’t really want to have appear elsewhere, one trick is to write the article, set its status tohidden
and then by usingstatus=hidden
in txp:article_custom you can make it appear exactly where you want it. Of course, replace 123 with your article ID# and myform with your form.
TXP Builders – finely-crafted code, design and txp
Offline
#4 2007-06-04 20:59:49
- brianlux0r
- Member
- Registered: 2007-06-04
- Posts: 41
Re: [howto] best way to control front page content
hey guys your answers have been very helpful I can see how all mentioned ideas function. Thanks a lot!
Now lets say I would like to have the main content of my front page controlled from one article, but I would like to have an excerpt from the most recently posted article for a given section or category in a designated section on the front page , i.e. recent article : blah blah … read more link for it… is that easily done as well?
Offline
Re: [howto] best way to control front page content
In a second div, you simply call txp:article_custom
again using the attributes section="mysection"
or category="mycategory"
and limit="n"
where n
is the number of articles you want to show. In your form set it up to show txp:title
, txp:excerpt
and <txp:permlink>read more...</txp:permlink>
(off the top of my head, check exact notation in the textbook tag listing – links in post above). If you don’t write excerpts for your article you can use a plugin such as rss_auto_excerpt to use x number of characters from your text, which will also do you a read more link automatically if you want.
TXP Builders – finely-crafted code, design and txp
Offline
#6 2007-06-08 22:58:04
- brianlux0r
- Member
- Registered: 2007-06-04
- Posts: 41
Re: [howto] best way to control front page content
meta description
Offline
#7 2008-12-02 21:21:41
- ChrisArchitect
- Member
- From: Canada
- Registered: 2007-06-20
- Posts: 25
Re: [howto] best way to control front page content
to revive this old thread….
how could one create a section page that pulls not only the article content, but all the article attributes like custom fields, article image, etc ?
Short of doing a redirect,
I have alot of custom fields that control other aspects of the page like what images are used, meta keywords etc ……
so the Page will output the ‘Sticky’ article if you’re on a article_list page ….but what about the rest of the content…..I don’t just want the main body to change
should I just look into doing a redirect? I would also rather not have to duplicate all of my basic Page designs into one per section with differing images etc ….would like to use the article attributes to control that
if this makes any sense to anyone, would appreciate any suggestions! cheers
Offline
#8 2008-12-02 21:34:16
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: [howto] best way to control front page content
ChrisArchitect wrote:
if this makes any sense to anyone
Hmm… I may be misunderstanding you, but just in case I’m not: you can use all the article related tags in one or more article forms to display all these fields.
Offline
#9 2008-12-02 21:52:43
- ChrisArchitect
- Member
- From: Canada
- Registered: 2007-06-20
- Posts: 25
Re: [howto] best way to control front page content
hmm
not really on an article page if on /Section/
so I can determine that because I’m on an article_list page (/Section/) I should only display 1 article with sticky status.
But what about the rest of the content?
In my Page design, when I get to the header image say, which changes from article to article, I can detect if it’s an individual_article and display article_image, but if I’m viewing /Section/ I’m not on an individual_article, so I need to somehow put:
<txp:article customfieldname /> and return the contents of that customfieldname for that article (which would be my sticky status)
I’m doing this all just so I can have a clean url structure on my site of
www.domain.com/Section1/
www.domain.com/Section2/
and have the sticky ‘main page’ for each Section displayed
am I going about this all wrong? I could not get gdp_permanent_links to do what I I’m describing…. :-S
thanks for the reply!
Offline
#10 2008-12-03 01:14:56
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: [howto] best way to control front page content
So on you section page you’ll have something like
<txp:if_article_list>
<txp:article status="sticky" limit="1" form="yourform" />
</txp:if_article_list>
where form ‘yourform’ displays let’s say title and body of your article.
You can do that again elsewhere on the page:
<txp:if_article_list>
<txp:article status="sticky" limit="1" form="otherform" />
</txp:if_article_list>
and form ‘otherform’ can have this:
<txp:custom_field name="customfieldname" />
and yet another form can have
<txp:article_image />
etcetera. You can repeat this code, with different form attributes, as many times as you like on your page, and use it to display your article fields wherever you like.
Offline
Re: [howto] best way to control front page content
This FAQ may help you too.
There are more than one way to achieve what you are trying.
Els already pointed you in one possible direction.
You can also render a particular article using <txp:article_custom id="3" form="myform" />
(txp:article_custom
is similar to txp:article
, but check the Textbook and the FAQs to find out the differences).
Also, if you are using Txp 4.0.7, you can use both txp:article
and txp:article_custom
as container tags, so you don’t need to create forms.
Following Els’s example, you can try this:
<txp:if_article_list>
<txp:article status="sticky" limit="1">
<txp:custom_field name="customfieldname" />
</txp:article>
</txp:if_article_list>
Or:
<txp:if_article_list>
<txp:article_custom id="15">
<txp:custom_field name="customfieldname" />
</txp:article>
</txp:if_article_list>
(I don’t have tested this but it should work… and if you could confirm it works… it would be great)
Offline
#12 2008-12-03 18:07:21
- ChrisArchitect
- Member
- From: Canada
- Registered: 2007-06-20
- Posts: 25
Re: [howto] best way to control front page content
maniqui wrote:
Also, if you are using Txp 4.0.7, you can use both
txp:article
andtxp:article_custom
as container tags, so you don’t need to create forms.
Following Els’s example, you can try this:
<txp:if_article_list>
<txp:article status=“sticky” limit=“1”> <txp:custom_field name=“customfieldname” />
</txp:article>
</txp:if_article_list>
You know what, I am on 4.0.7 and did try to understand what exactly the benefit of new container capabilties on those tags was ..and I tried that, but must not have nested them correctly …
But it turns out, it does work, fantastically.
So now I have those dynamic areas of the page pulling specific ‘sticky’ home page article content on /Section/ URLs
thanks so much for the attention to this
Now I can move on in my design to other things..heh :-S
Offline