Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-29 07:41:34

bokane
Member
From: Beijing, China
Registered: 2005-10-24
Posts: 13
Website

including older articles by ID doesn't seem to work.

Hi —

I’ve got a custom field for posts called “archiveID” which contains the ID number of earlier posts to be included after main blog posts. I though I had it set up so that if there is a number in “archiveID,” TXP will include the corresponding post; if not, not.

I’ve got about half of what I wanted: on posts with an archived entry ID defined, TXP includes an archived entry. The same one, no matter which entry ID I’ve entered.

The code I’m using:

<code><txp:if_custom_field name=“archiveID”><!— Archive article ID: <txp:custom_field name=archiveID /> —> <txp:article_custom form=“telecom_divider” limit=“1” /> <txp:article_custom id=”<txp:custom_field=archiveID limit=1 form=“include_archive” limit=“1” /> <txp:else />
</txp:if_custom_field>
<txp:article_custom form=“telecom_divider” limit=“1” /></code>

(“include_archive” is just formatting for the archived article.)

The weird things: the first time I call <code><txp:custom_field name=“archiveID” /></code>, in the commented-out bit, it displays the number perfectly correctly. It’s when TXP is supposed to be including the old article that the weirdness occurs.

Is my code just wrong?

Offline

#2 2005-12-29 17:34:38

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

Re: including older articles by ID doesn't seem to work.

Tags cannot be used as attribute values.

Offline

#3 2005-12-30 06:54:37

bokane
Member
From: Beijing, China
Registered: 2005-10-24
Posts: 13
Website

Re: including older articles by ID doesn't seem to work.

Well, darn. Is there any way of doing this, then? Or will I just have to use PHP includes or something of the sort?

Offline

#4 2005-12-30 08:42:09

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

Re: including older articles by ID doesn't seem to work.

<txp:if_custom_field name="archiveID">

	<txp:article_custom limit="1" form="telecom_divider" />

	<txp:php>echo article_custom(array(
		'id'    => custom_field(array('name' => 'archiveID')),
		'limit' => '1',
		'form'  => 'include_archive'
	));</txp:php>

</txp:if_custom_field>

<txp:article_custom limit="1" form="telecom_divider" />

Offline

#5 2005-12-30 08:46:25

bokane
Member
From: Beijing, China
Registered: 2005-10-24
Posts: 13
Website

Re: including older articles by ID doesn't seem to work.

Oh, fantastic — thanks very much!

Offline

#6 2005-12-30 08:54:32

bokane
Member
From: Beijing, China
Registered: 2005-10-24
Posts: 13
Website

Re: including older articles by ID doesn't seem to work.

Hm – doesn’t seem to be working; I’m stilll getting the same article as before, rather than the one I specified in archiveID…

Offline

#7 2005-12-30 15:02:57

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

Re: including older articles by ID doesn't seem to work.

The id attribute can only contain one article id#.

Offline

#8 2006-01-02 03:04:17

bokane
Member
From: Beijing, China
Registered: 2005-10-24
Posts: 13
Website

Re: including older articles by ID doesn't seem to work.

Is that one per page, or one per post? At the moment, I’m displaying multiple posts on one page, so maybe that’d explain it…

Offline

#9 2006-01-02 05:58:22

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

Re: including older articles by ID doesn't seem to work.

Neither. You can call the article_custom tag as many times on a page as you want, but you can’t pass two id#s at once. I’m saying that because you said:

…which contains the ID number of earlier post*s*…

you said it in plural, so I thought maybe you were putting more than one id# into the custom field.

Offline

#10 2006-01-03 06:45:39

bokane
Member
From: Beijing, China
Registered: 2005-10-24
Posts: 13
Website

Re: including older articles by ID doesn't seem to work.

Hm — it’s still including the same article for all posts. That is, I have a few posts, each with a different archiveID defined, displaying on the same page, and all display the same article – the first archiveID referenced in the page – rather than the one defined.

Offline

Board footer

Powered by FluxBB