Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-03 18:05:42

iamjhammons
Member
Registered: 2005-11-18
Posts: 13

apply dif layout to article from a section when on frontpage

hi,

i’m trying to apply a special layout to articles from a particular section when shown on the front page. there is info on this exact thing in faq section but i can’t seem to get it to work. i must be doing something wrong. basically. i want articles from my “news” section to display a bit different when on the front page. as an example, let’s say i’d like the “news” articles to not display the posted date when on the front page, but should in the news section.

here’s what the faq says:

Use the txp:if_article_section tag in your article form:

<code><txp:if_article_section name=“linklog”>
<!— section “linklog” only —>
<div class=“linklog”><txp:body /></div>
<txp:else />
<!— all other sections —>
<txp:title />
<txp:body />
</txp:if_article_section></code>
<br>
and i assumed this would mean i would do something like this to remove the posted date from the news articles on the frontpage.<br>

<code><txp:if_article_section name=“news”>
<!— section “news” only —>
<h2><txp:posted /></h2>
<txp:body />
<txp:else />
<!— all other sections —>
<txp:body />
</txp:if_article_section></code>
<br>
i’m not sure if where “linklog” is in the example above, if i should replace that with “default” or “news” i’ve tried both but it doesn’t seem to work. not sure what else i could be doing wrong so any help would be greatly appreciated! thanks, j

Last edited by iamjhammons (2005-12-03 18:07:52)

Offline

#2 2005-12-04 01:25:19

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: apply dif layout to article from a section when on frontpage

If you want to remove the dates from the news section articles you need to reverse your code like so:-

<code>
<txp:if_article_section name=“news”>
<!— section “news” only —>
<txp:body />
<txp:else />
<!— all other sections —>
<h2><txp:posted /></h2>
<txp:body />
</txp:if_article_section></code>


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2005-12-04 19:00:56

iamjhammons
Member
Registered: 2005-11-18
Posts: 13

Re: apply dif layout to article from a section when on frontpage

hrmm, i still can’t seem to get this to work. i’m wondering if i’m doing something else wrong. maybe it would help if i explain what i’m doing in general. basically, i’m setting up a band site. it has three sections, shows, press and news. on the home page. i want to display one post from each section (i.e. the most current info, one news post, one press post and the next show the band is having). so i’ve set up the sections, created forms for each type of post (news, shows and press) and i’ve put the following on the front page.

<p><code><h2>news</h2>
<txp:article_custom form=“news” limit=“1” section=“news” sortby=“Posted” sortdir=“desc” listform=“news” /></code></p>

<p><code><h2>shows</h2><txp:article_custom form=“shows” limit=“1” section=“shows” sortby=“Posted” sortdir=“desc” listform=“shows” /></code></p>

<p><code><h2>press</h2><txp:article_custom form=“press” limit=“1” section=“press” sortby=“Posted” sortdir=“desc” listform=“press” /></code></p>

each one of the above has a link to view all. so what i’m hoping to achieve. is a frontpage with the most current post from each of these sections. and to view all posts you click on the “view all” link that takes you to all the post for each section (www.mysite.com/news/, www.mysite.com/press, www.mysite.com/shows)

so what i’m trying to do with the code in my original post is display the most current news post on the front page a bit differently than the way it would appear on the www.mysite/news/ page where all the news posts reside. so as an example, i’d like to remove the posted date from the most current news post on the homepage but on the www.mysite.com/news page, i’d like the posted date to appear.

wow, that was a mouthful but having all that said i’m wondering if i’m going about this the wrong way as i’m new to textpattern. thanks!

Last edited by iamjhammons (2005-12-04 19:03:45)

Offline

#4 2005-12-04 20:05:38

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: apply dif layout to article from a section when on frontpage

Hi iamjhammons

You could use something like:

<code>
<txp:if_section name=”“>
<h2>news</h2>
<txp:article_custom form=“news” limit=“1” section=“news” sortby=“Posted” sortdir=“desc” listform=“news” />
<h2>shows</h2><txp:article_custom form=“shows” limit=“1” section=“shows” sortby=“Posted” sortdir=“desc” listform=“shows” />
<h2>press</h2><txp:article_custom form=“press” limit=“1” section=“press” sortby=“Posted” sortdir=“desc” listform=“press” />
<txp:else />
<txp:article form=“myArticleForm” listform=“myArticleWhenInAListForm” />
</txp:if_section>
</code>

That means: “if we are in frontpage (name=”“), show this. Else (if we are not in frontpage, so we are in a section), show the article list using the form specified by listform attribute, or show an individual article, using the form specified in form attribute.”

For the “View All” link, in each of your article forms (“news”, “press”, “shows”), you could add something like this:
<code><a href=”/<txp:section />” title=“View all post in <txp:section title=“1” />”>View all</a>.</code>

Last edited by maniqui (2005-12-04 20:08:13)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2005-12-05 03:06:05

iamjhammons
Member
Registered: 2005-11-18
Posts: 13

Re: apply dif layout to article from a section when on frontpage

hey, thanks so much.

so just so i understand. the above code goes on my frontpage? for some reason i thought what the faq described on how to achieve this you have to modify the article form. also, what would i put on my “news” page, code wise, where i want all the news articles to appear. currently i just have: <p><code><txp:article_custom form=“news” section=“news” sortby=“Posted” sortdir=“desc” listform=“news” /></code></p>

thanks! j

Last edited by iamjhammons (2005-12-05 03:06:46)

Offline

#6 2005-12-05 03:16:39

iamjhammons
Member
Registered: 2005-11-18
Posts: 13

Re: apply dif layout to article from a section when on frontpage

oh hey! thanks so much. that was super helpful and i think i got it going the way i want.

i made my form for the “news” section look like this:

<p><code><txp:if_section name=”“>
<div class=“top”><txp:body/></div>
<txp:else />
<h2><txp:posted /></h2>
<div class=“top”><txp:body/></div>
</txp:if_section></code></p>

and that did the trick! i don’t think i realized before that the frontpage isn’t a section. thanks! j

Last edited by iamjhammons (2005-12-05 03:16:59)

Offline

#7 2005-12-05 08:26:44

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: apply dif layout to article from a section when on frontpage

Just to muddy the waters a bit you can use “if_section” in the article form template if that’s the way you prefer to do it. This would give a flexible form that could be used in different sections to output different content or not as the case may be. I’ve used this method in the TXP Borderline Chaos (http://textgarden.org/borderline-chaos) theme to format the article in a different way depending on whether you are on the front-page or back-page.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

Board footer

Powered by FluxBB