Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-05-17 19:13:23
- Aleksandersen
- Member
- From: Lillehammer, Norway
- Registered: 2007-04-12
- Posts: 77
Excepts stripped of markup (for meta descriptions)
Hi,
How can I print excepts stripped of markup?
<meta name="description" value="Except without <html>markup</html>, please.">
I use excepts with markup several places on my site. But in the example above, I would like it without the markup.
Offline
Re: Excepts stripped of markup (for meta descriptions)
You can do this:
http://sonspring.com/journal/lazy-textpattern-seo
Or use this:
etz_striptags
Offline
Re: Excepts stripped of markup (for meta descriptions)
<meta name="description" value="<txp:php>echo strip_tags(excerpt(array()));</txp:php>">
Offline
#4 2007-05-17 19:44:47
- Aleksandersen
- Member
- From: Lillehammer, Norway
- Registered: 2007-04-12
- Posts: 77
Re: Excepts stripped of markup (for meta descriptions)
Thanks, Ruud. :) Does that work with all txp tags?
Offline
#5 2007-05-17 19:58:58
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Excepts stripped of markup (for meta descriptions)
maniqui wrote:
You can do this:
http://sonspring.com/journal/lazy-textpattern-seo
Thanks maniqui for this link. Until now I used a custom field for the description, but often forgot to fill it. This method is perfect!
Offline
Re: Excepts stripped of markup (for meta descriptions)
It should work with all TXP tags that output (X)HTML code
Offline
#7 2007-05-17 21:29:30
- Aleksandersen
- Member
- From: Lillehammer, Norway
- Registered: 2007-04-12
- Posts: 77
Re: Excepts stripped of markup (for meta descriptions)
Can someone spot my syntax error?
<meta name="description" content="<txp:php>if excerpt(array()) {
echo(strip_tags(excerpt(array()));
} else {
echo("Default description."); }</txp:php>">
Offline
Re: Excepts stripped of markup (for meta descriptions)
Add ( ) around the “if” condition and add another closing ) at the end of the strip_tags line, just before the semicolon.
PS. this is shorter:
<meta name="description" content="<txp:php>echo (excerpt(array()) ? strip_tags(excerpt(array())) :
'Default description.');</txp:php>">
Last edited by ruud (2007-05-17 21:40:35)
Offline
#9 2007-06-04 01:20:25
- Aleksandersen
- Member
- From: Lillehammer, Norway
- Registered: 2007-04-12
- Posts: 77
Re: Excepts stripped of markup (for meta descriptions)
I cannot see why this code does not work. Anyone spotting my error? A shorter version would be appriciated too!
<meta name="description" content="<txp:php>if (except(array())) {
echo(strip_tags(excerpt(array()));
echo(' There are '); echo(comments_count(array)); echo(' comments.'); }
else { echo('Default description.'); }</txp:php>">
Last edited by Aleksandersen (2007-06-04 01:20:56)
Offline
#10 2007-06-04 04:32:38
- FireFusion
- Member
- Registered: 2005-05-10
- Posts: 698
Re: Excepts stripped of markup (for meta descriptions)
Good topic
Offline
#11 2007-06-04 05:03:49
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Excepts stripped of markup (for meta descriptions)
Your first line says except
rather than excerpt
.
Offline
Re: Excepts stripped of markup (for meta descriptions)
daniel, you’ve made a typo, it’s “excerpt”, not “except” and on the second line you have one “)” too many.
PS. you don’t need “( )” around things you want to echo.
Offline