Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-02-02 15:41:53

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Make article_custom ignore current article in produced list?

Would be invaluable!

Any TXP gurus have any ideas? :¬)

Offline

#2 2012-02-02 15:48:00

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

Re: Make article_custom ignore current article in produced list?

hi

<txp:variable name="myid" value='<txp:article_id />' />
<txp:article_custom category="somecat" section="somesection">
<txp:if_article_id id='<txp:variable name="myid" />'>
<txp:else />
<txp:title />
</txp:if_article_id>
</txp:article_custom>

something like that! (not tested but should work)

Offline

#3 2012-02-02 15:49:29

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: Make article_custom ignore current article in produced list?

Trying now – thanks very much for the help!

TXP mods and developers are so helpful, always blown away by it :¬)

Offline

#4 2012-02-02 16:12:48

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: Make article_custom ignore current article in produced list?

Hmm, still prints out current article!

Offline

#5 2012-02-02 16:32:53

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

Re: Make article_custom ignore current article in produced list?

something to add to the code:

<txp:if_individual_article>
<txp:variable name="myid" value='<txp:article_id />' />
<txp:article_custom category="somecat" section="somesection">
<txp:if_article_id id='<txp:variable name="myid" />'>
<txp:else />
<txp:title />
</txp:if_article_id>
</txp:article_custom>
<txp:else />
<txp:article_custom category="somecat" section="somesection">
<txp:title />
</txp:article_custom>

hi

you can use tag trace to see what’s going on (in admin/prefs put site on debugging and then view your site and see the source code)

Offline

#6 2012-02-02 17:00:35

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: Make article_custom ignore current article in produced list?

It’s always launched from an article page, so is that extra condition necessary?

Also worth noting, the code on the TXP docs didn’t work either (output nothing):

Example 2: Display a list of articles omitting current article

<txp:article_custom label="related" labeltag="h4" section='<txp:section />' wraptag="ul">
<txp:if_article_id>
<txp:else />
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:if_article_id>
</txp:article_custom>

Offline

#7 2012-02-02 17:07:31

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

Re: Make article_custom ignore current article in produced list?

I’m using the example above with success


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

Offline

#8 2012-02-02 17:11:55

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: Make article_custom ignore current article in produced list?

Could it be the fact I’m using keywords perhaps? Here’s the code:

<txp:article_custom section="weddings,venue" keywords="<txp:custom_field name='related'/>">
	<txp:if_article_id>
	<txp:else />
		<div class="container testimonial">
		    <div class="column span-3"><txp:article_image thumbnail="1" /></div>
		    <div class="column span-17 prepend-1 last">
		        <h2><txp:permlink title="<txp:title />"><txp:title /></txp:permlink></h2>
		        <blockquote>
		            <p><txp:excerpt /></p>
		        </blockquote>
		    </div>
		</div>
	</txp:if_article_id>
</txp:article_custom>

Last edited by rossharvey (2012-02-02 17:12:43)

Offline

#9 2012-02-02 17:44:15

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Make article_custom ignore current article in produced list?

rossharvey wrote:

Could it be the fact I’m using keywords perhaps?

It’s rather the way you’re nesting the keywords custom_field tag: double/single quotes!

Try:

<txp:article_custom section="weddings,venue" keywords='<txp:custom_field name="related"/>'>
	<txp:if_article_id>
	<txp:else />
		<div class="container testimonial">
		    <div class="column span-3"><txp:article_image thumbnail="1" /></div>
		    <div class="column span-17 prepend-1 last">
		        <h2><txp:permlink title="<txp:title />"><txp:title /></txp:permlink></h2>
		        <blockquote>
		            <p><txp:excerpt /></p>
		        </blockquote>
		    </div>
		</div>
	</txp:if_article_id>
</txp:article_custom>

Last edited by uli (2012-02-02 17:45:06)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#10 2012-02-02 17:47:48

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: Make article_custom ignore current article in produced list?

The nested quotes work that way, ‘x’ within “y”.

The article_custom call is not the issue, it’s the conditional call for the current article

This, by itself, works. But of course it doesn’t exclude the current article.

<txp:article_custom section="weddings,venue" keywords="<txp:custom_field name='related'/>"/>

Last edited by rossharvey (2012-02-02 17:48:07)

Offline

#11 2012-02-02 17:53:13

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Make article_custom ignore current article in produced list?

rossharvey wrote:

The nested quotes work that way, ‘x’ within “y”.

Hrrm? Exceptional!

Is keywords as a name for a custom field allowed?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#12 2012-02-02 18:02:23

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: Make article_custom ignore current article in produced list?

The custom field name is ‘related’, and I pipe that value into the keywords attribute of article_custom.

Offline

Board footer

Powered by FluxBB