Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-13 23:06:15

nikolay
New Member
Registered: 2009-01-04
Posts: 6

Hide some words

In my blog I have some rubrics which names I add to the article titles. Example:

“Photo of the week: blah-blah” where “photo of the week” is a week rubric and “blah-blah” is a particular title. The rubric name is a part of the title field, it isn’t a separate field, because I want it to be included in the RSS titles as well.

However, in lists of related articles I want to skip this part of the title, because all articles in such kind of lists are from the same rubric (rubrics are categories as well):

Instead of:

“More photos of the week:
  • Photo of the week: Blah-blah
  • Photo of the week: Nah-nah
  • Photo of the week: Foo-foo”

… I want:

“More photos of the week:
  • Blah-blah
  • Nah-nah
  • Foo-foo”

So, how can skip “Photo of the week” here?

For example, I could use a custom field for the short title, but how can I use that custom field in the related articles list?
Or, is it possible to hide the words “photo of the week” somehow automatically?

Offline

#2 2009-04-13 23:13:41

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Hide some words

Drop this into your article form:

<txp:php>
echo str_replace('Photo of the week: ', '', $GLOBALS['thisarticle']['title']);
</txp:php>

Offline

#3 2009-04-14 07:11:45

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Hide some words

adi_title would be able to do this for you.

Offline

#4 2009-04-14 09:10:08

nikolay
New Member
Registered: 2009-01-04
Posts: 6

Re: Hide some words

Thank you both jm and gomedia.

Both solutions are useful but… I want to use these changed titles for Related Artcicles list.

However the <txp:related_articles /> tag doesn’t support a form attribute, so I can’t specify which adi_title version to use, as well as I can’t apply the php code there.

The <txp:related_articles /> tag always use the default title.

Any suggestions?

Last edited by nikolay (2009-04-14 09:11:48)

Offline

#5 2009-04-14 09:26:00

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Hide some words

Maybe chh_related_articles in conjunction with adi_title?

Offline

#6 2009-04-14 09:31:17

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Hide some words

Or we take Jon-Michaels example and tweak it a little bit. For example:

<txp:php>
	echo
		str_replace('Photo of the week: ','',
			parse(
				'<txp:related_articles />'
			)
		)
	;
</txp:php>

Last edited by Gocom (2009-04-14 09:31:55)

Offline

#7 2009-04-14 09:53:12

nikolay
New Member
Registered: 2009-01-04
Posts: 6

Re: Hide some words

Thank you guys!

The Gocom/jm php code works :) So I won’t install chh_related_articles at this moment.

I will use adi_title for other types of lists.

Thanks.

Offline

#8 2009-04-14 15:24:06

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Hide some words

Nice work, Gocom.

nikolay, related_articles accepts a form attr (or $thing), so you can do:

<txp:related_articles>
    <txp:title/>
</txp:related_articles>

Offline

#9 2009-04-14 15:41:12

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Hide some words

jm wrote:

nikolay, related_articles accepts a form attr (or $thing), so you can do:

Yeah, current versions do… thanks for reminding :D But anyway that tweaking makes it faster by x times, where x is the amount of related articles.

Btw, JM, i lolled so hard to your What? My name is… :D Funny. Will that make end of world’s name abuse. Will our hereo be saved? Next time on “Not J on Michael!”

Offline

Board footer

Powered by FluxBB