Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-07-31 15:50:06

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

First Article Help

Hi this is a form I use for outputting a list of articles on my blog page. the idea is that the first article will have full body text and then the rest just the intros. BUT the posts are limited to 5 and then span over numerous pages. The problem is that on page two the first article will also spit out full body text, so what im wanting to do is as well as check for if_first_article, also check that its the first page.

<div class="post">

	<div class="post-date">
		<span><txp:posted format="%d/%m/%Y" /></span>
	</div>
	<div class="post-comments">
		<span><a href="<txp:permlink />#comments" title="Add a Comment"><txp:comments_count /></a></span>
	</div>

	<h2><a href="<txp:permlink />" title="<txp:title />"><txp:title /></a></h2>


	<txp:if_first_article><txp:body /><txp:else /><txp:excerpt /></txp:if_first_article>

	<txp:if_first_article><txp:else /><p><a href="<txp:permlink />" title="<txp:title />">continue reading...</a></p></txp:if_first_article>

</div>

<txp:if_last_article><txp:else /><hr /></txp:if_last_article>

~ Cameron

Offline

#2 2009-07-31 15:55:53

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: First Article Help

Could use this to check for first page.


Code is topiary

Offline

#3 2009-07-31 16:14:11

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: First Article Help

Will this detect the first page or the front page?


~ Cameron

Offline

#4 2009-07-31 16:19:43

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: First Article Help

driz wrote:

Will this detect the first page or the front page?

Sounds like it to me.

soo_if_frontpage evaluates to true if the current page context is:

  • an article list, and;
  • not search results, and;
  • not a listing of articles by category, and;
  • not a listing of articles by author, and;
  • not a listing of articles by month, and;
  • (optionally) in one of the sections listed in the section attribute, and;
  • (optionally) a single-page list or the first page of a multi-page list, if the pg attribute is set.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#5 2009-08-02 11:16:10

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: First Article Help

Is the correct way of using it?

	<txp:soo_if_frontpage>
		<txp:if_first_article>
			<txp:body />
		<txp:else />
			<txp:excerpt />
		</txp:if_first_article>
	<txp:else />
		<txp:excerpt />
	</txp:soo_if_frontpage>

Last edited by driz (2009-08-02 11:35:23)


~ Cameron

Offline

#6 2009-08-02 11:30:18

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: First Article Help

driz wrote:

Is the correct way of using it?

<txp:if_soo_page><txp:if_first_article><txp:body /></txp:if_first_article><txp:else /><txp:excerpt /></txp:if_soo_page>

No:) Try

<txp:soo_if_frontpage><txp:if_first_article><txp:body /><txp:else /><txp:excerpt /></txp:if_first_article><txp:else /><txp:excerpt /></txp:soo_if_frontpage>


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2009-08-02 11:36:49

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: First Article Help

Yeh tried that, but it only works on front page, when i go to page 2 they are all spitting out the body instead of ONLY the excerpts!

EDIT: adding pg="1" to the <txp:soo_if_frontpage> fixes the problem. Thanks.

So for anyone who also wants to do this, here is the full code you need to put in your article form:

<txp:soo_if_frontpage pg="1">
		<txp:if_first_article>
			<txp:body />
		<txp:else />
			<txp:excerpt />
			<p><a href="<txp:permlink />" title="<txp:title />">continue reading...</a></p>
		</txp:if_first_article>
	<txp:else />
		<txp:excerpt />
		<p><a href="<txp:permlink />" title="<txp:title />">continue reading...</a></p>
	</txp:soo_if_frontpage>

Last edited by driz (2009-08-02 11:42:25)


~ Cameron

Offline

#8 2009-08-02 11:43:21

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: First Article Help

Try this:

<txp:soo_if_frontpage pg="1">
	<txp:if_first_article>
		<txp:body />
	<txp:else />
		<txp:excerpt />
		<p><a href="<txp:permlink />" title="<txp:title />">continue reading...</a></p>
	</txp:if_first_article>
<txp:else />
	<txp:excerpt />
	<p><a href="<txp:permlink />" title="<txp:title />">continue reading...</a></p>
</txp:soo_if_frontpage >

Whitespace added to make the logic a little clearer.

Kind of a pain that you have to repeat the excerpt/permlink block, but that’s the way it is with stacked conditionals when you want to cover every case. Note that the pg attribute is a boolean — it does not refer to a particular page number.

Edit: too slow!

Last edited by jsoo (2009-08-02 11:44:24)


Code is topiary

Offline

Board footer

Powered by FluxBB