Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-10-11 13:44:41

goldenmeanie
Member
From: Providence, RI
Registered: 2011-09-29
Posts: 10

Article tag not working, forced to use article_custom

I have this code on a page used by a section.

<txp:if_individual_article>
  <txp:article />
<txp:else />
  <txp:article limit="5" />
</txp:if_individual_article>

I think it should show the last five articles (blog style) when I load site.com/section/ and then just the relevant article when I load site.com/section/article-title. But I can only get site.com/section to work using article_custom and specifying which section. But then I don’t get paging. Have I misunderstood how this is supposed to work?

I’ve just upgraded an old site from 4.0.4 to 4.4.1. Lot’s of stuff was broken, but I’ve got everything but this one issue locked down now.

Thank you for any help you can offer!

Offline

#2 2011-10-11 16:37:13

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 595
Website

Re: Article tag not working, forced to use article_custom

Have you tried pulling out the else clause and putting that article tag inside if_article_list?

Offline

#3 2011-10-11 16:50:37

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

Re: Article tag not working, forced to use article_custom

also what do you have in your default form?


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

Offline

#4 2011-10-11 18:47:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: Article tag not working, forced to use article_custom

Your logic seems sound to me. Although it shouldn’t make any difference in this case, one thing I would add is that the <txp:article /> tag is context sensitive such that you shouldn’t need the conditional. You can get away with just:

<txp:article limit="5" />

With just that tag, on article list pages you’ll get 5 articles passed through your default Form; on individual article pages you’ll get a single article passed through the default Form. If you want to change which Forms are used you can use the form (for individual articles) and listform (for landing pages) attributes to specify how to display each type. If you omit listform, then form will be used for both, and if you omit them all then the default Form is used.

In this case though I can’t think why they wouldn’t show up. As long as you have:

  • articles assigned to the current /section
  • they are Published in the past
  • they are set to Live status (not Sticky or anything else)
  • (if being viewed on the front page) have On Front Page set to ‘yes’ in the Presentation->Sections tab

then the articles will appear. Very odd that they’re not.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2011-10-11 22:26:39

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

Re: Article tag not working, forced to use article_custom

And of course you can always post a tag trace :)

Offline

#6 2011-10-13 12:35:48

goldenmeanie
Member
From: Providence, RI
Registered: 2011-09-29
Posts: 10

Re: Article tag not working, forced to use article_custom

Thanks folks, you’ve given me a few more things to try. This is a nighttime project for me so I won’t be able to give them a go until this evening. I very much appreciate your responses!

Offline

#7 2011-10-14 02:22:14

goldenmeanie
Member
From: Providence, RI
Registered: 2011-09-29
Posts: 10

Re: Article tag not working, forced to use article_custom

maruchan wrote:

Have you tried pulling out the else clause and putting that article tag inside if_article_list?

I just tried this to no avail. Thanks for the suggestion though!

Offline

#8 2011-10-14 02:24:01

goldenmeanie
Member
From: Providence, RI
Registered: 2011-09-29
Posts: 10

Re: Article tag not working, forced to use article_custom

colak wrote:

also what do you have in your default form?

Default form simply has <txp:article limit="5" /> and it works great.

Offline

#9 2011-10-14 02:31:49

goldenmeanie
Member
From: Providence, RI
Registered: 2011-09-29
Posts: 10

Re: Article tag not working, forced to use article_custom

Bloke wrote:

Your logic seems sound to me. Although it shouldn’t make any difference in this case, one thing I would add is that the <txp:article /> tag is context sensitive such that you shouldn’t need the conditional. You can get away with just:
<txp:article limit="5" />

This was my assumption too, and it’s where I started. Unfortunately I can’t get anything to render anywhere but the front page without resorting to the conditionals and article_custom.

In this case though I can’t think why they wouldn’t show up. As long as you have:

  • articles assigned to the current /section
  • they are Published in the past
  • they are set to Live status (not Sticky or anything else)
  • (if being viewed on the front page) have On Front Page set to ‘yes’ in the Presentation->Sections tab

I double-checked and my articles fit all these criteria. Set to current section, published in the past, live, not front page but I’m not looking there either.

Offline

#10 2011-10-14 02:40:48

goldenmeanie
Member
From: Providence, RI
Registered: 2011-09-29
Posts: 10

Re: Article tag not working, forced to use article_custom

Els wrote:

And of course you can always post a tag trace :)

Tag Trace with code as in OP:

<!-- Runtime:    0.0804 -->
<!-- Query time: 0.069474 -->
<!-- Queries: 15 -->
<!-- Memory: 2742Kb, <txp:title /> -->
<!-- txp tag trace: 
[SQL (0.00019097328186035): select name, data from txp_lang where lang='en-us' AND ( event='public' OR event='common')]
[SQL (8.7976455688477E-5): select name, code, version from txp_plugin where status = 1 AND type IN (0,1) order by load_order]
[SQL (6.8187713623047E-5): select name from txp_section where `name` like 'testwod' limit 1]
[SQL (7.6055526733398E-5): select page, css from txp_section where name = 'testwod' limit 1]
[SQL (7.7009201049805E-5): select user_html from txp_page where name='testwod']
[Page: testwod]
<txp:page_title />
<txp:feed_link flavor="atom" format="link" label="Atom" />
<txp:feed_link flavor="rss" format="link" label="RSS" />
<txp:link_to_home>
	<txp:site_name />
</txp:link_to_home>
<txp:output_form form="nnav" />
	[SQL (0.0001518726348877): select Form from txp_form where name='nnav']
	[Form: nnav]
<txp:if_individual_article>
	[<txp:if_individual_article>: false]
	<txp:article limit="5" />
		[SQL (8.082389831543E-5): select name from txp_section where searchable != '1']
		[SQL (0.032258033752441): select count(*) from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and (`Title` like '%/testwod%' or `Body` like '%/testwod%') ]
		[SQL (0.023123979568481): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod, match (`Title`, `Body`) against ('/testwod') as score from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and (`Title` like '%/testwod%' or `Body` like '%/testwod%')  order by score desc limit 0, 5]
</txp:if_individual_article>

Tag Trace with <txp:article_custom section="testwod" limit="5" /> work-around in the original conditional:

<!-- txp tag trace: 
[SQL (0.00014996528625488): select name, data from txp_lang where lang='en-us' AND ( event='public' OR event='common')]
[SQL (9.5129013061523E-5): select name, code, version from txp_plugin where status = 1 AND type IN (0,1) order by load_order]
[SQL (9.4175338745117E-5): select name from txp_section where `name` like 'testwod' limit 1]
[SQL (8.8930130004883E-5): select page, css from txp_section where name = 'testwod' limit 1]
[SQL (9.918212890625E-5): select user_html from txp_page where name='testwod']
[Page: testwod]
<txp:page_title />
<txp:feed_link flavor="atom" format="link" label="Atom" />
<txp:feed_link flavor="rss" format="link" label="RSS" />
<txp:link_to_home>
	<txp:site_name />
</txp:link_to_home>
<txp:output_form form="nnav" />
	[SQL (9.2029571533203E-5): select Form from txp_form where name='nnav']
	[Form: nnav]
<txp:if_individual_article>
	[<txp:if_individual_article>: false]
	<txp:article_custom section="testwod" limit="5" />
		[SQL (0.00070714950561523): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('testwod') order by Posted desc limit 0, 5]
		[article 1909]
		[SQL (9.7990036010742E-5): select Form from txp_form where name='default']
		[Form: default]
		<txp:permlink>
			<txp:title />
		</txp:permlink>
		<txp:body />
		<txp:comments_invite />
		<txp:if_individual_article>
			[<txp:if_individual_article>: false]
		</txp:if_individual_article>
		[article 1908]
		[Form: default]
		<txp:permlink>
			<txp:title />
		</txp:permlink>
		<txp:body />
		<txp:comments_invite />
		<txp:if_individual_article>
			[<txp:if_individual_article>: false]
		</txp:if_individual_article>
</txp:if_individual_article>

Offline

#11 2011-10-14 11:06:42

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,538
Website GitHub Twitter

Re: Article tag not working, forced to use article_custom

goldenmeanie a écrit:

colak wrote:

also what do you have in your default form?

Default form simply has <txp:article limit="5" /> and it works great.

euh no, the default form is found in form tab and it s named “default” and it s not containing txp:article tag! but it s something like this :

<txp:if_individual_article>
<h1 class="entry-title"><txp:permlink><txp:title /></txp:permlink></h1>
<txp:else />
<h3 class="entry-title"><txp:permlink><txp:title /></txp:permlink></h3>
</txp:if_individual_article>

<p class="published"><txp:posted /></p>

<div class="entry-content">
<txp:body />
</div>

<address class="vcard author">— <span class="fn"><txp:author /></span></address>

<p class="tags"><txp:category1 title="1" link="1" />, <txp:category2 title="1" link="1" /></p>

<txp:comments_invite wraptag="p" />

<div class="divider"><txp:image id="1" /></div>

and like bloke advise you remove the txp:if_individual_article test, you put only <txp:article limit=“5” /> and it should work.

Cheers

Offline

#12 2011-10-14 16:12:05

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

Re: Article tag not working, forced to use article_custom

I don’t get this:

and (`Title` like '%/testwod%' or `Body` like '%/testwod%')

and this:

match (`Title`, `Body`) against ('/testwod')

Could there be something in article form ‘default’ that causes this? Looking at the query I’m not surprised that you don’t get any articles.

Offline

Board footer

Powered by FluxBB