Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-06 14:08:21

christina.helen
Member
From: California
Registered: 2009-03-20
Posts: 38

How to remove <p> tags on excerpt

Hi! My index page is no longer validating (xhtml 1.0 strict) because of the <p> tag that my form adds around my image which is the excerpt.

The form I am using is

<txp:if_first_article><ul id="portfolio"></txp:if_first_article>
	<li><a href="<txp:permlink />"><txp:excerpt /></a></li>
<txp:if_last_article></ul></txp:if_last_article>

which is outputting the following html

 <ul id="portfolio">
 <li><a href="http://www.helpshack.com/test/portfolio/roman-loranc"> <p><img src="http://www.helpshack.com/test/images/roman_thumb.gif" alt="Roman Loranc" /></p></a></li>
 <li><a href="http://www.helpshack.com/test/portfolio/coastal-fresh-farms"> <p><img src="http://www.helpshack.com/test/images/coastal_thumb.gif" alt="Coastal Fresh Farms" /></p></a></li>
 <li><a href="http://www.helpshack.com/test/portfolio/waterbird-gallery"> <p><img src="http://www.helpshack.com/test/images/waterbird_thumb.gif" alt="Waterbird Gallery" /></p></a></li>
 <li><a href="http://www.helpshack.com/test/portfolio/helpshack-10"> <p><img src="http://www.helpshack.com/test/images/helpshackv1_thumb.gif" alt="helpshAck v1.0" /></p></a></li>
 </ul>

Why is the <p> added and is there a way to remove it so my html will validate? Thanks for your help in advance.

Offline

#2 2009-04-06 14:17:08

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

Re: How to remove <p> tags on excerpt

is there a reason you are not using article_image ?
I think that it will be more appropriate considering what you are trying to achieve.

>Edit to answer your question though… If you don’t want the p tag all you need to do is start the line with a space:)

Last edited by colak (2009-04-06 14:18:13)


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

Offline

#3 2009-04-06 14:56:31

christina.helen
Member
From: California
Registered: 2009-03-20
Posts: 38

Re: How to remove <p> tags on excerpt

Hi colak. I am already using article_image for the larger photos so needed Excerpt for the thumbnails. I added the space before my image in Excerpt and the <p> tags were removed. Thanks for your advice!

Offline

#4 2009-04-06 15:39:53

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

Re: How to remove <p> tags on excerpt

Hi christina helen

It just seems that it is a waste of the excerpt which is also syndicated. A custom field might be better fo you

Something like

<ul id="portfolio">
<txp:if_custom_field name="img"><li><txp:permlink><img src="<txp:custom_field name="img">"/></txp:permlink></li></txp:if_custom_field>
</ul>

might be more appropriate as it will only add a li only if the field is filled.

My suggestion would be to use the txp tag <txp:image id="#" /> in the custom filed as it will/should update the urls when/if you move your install.

Last edited by colak (2009-04-06 15:45:21)


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

Offline

#5 2009-04-06 15:55:53

graeme
Plugin Author
Registered: 2004-06-21
Posts: 337
Website

Re: How to remove <p> tags on excerpt

christina.helen wrote:

Why is the <p> added and is there a way to remove it so my html will validate? Thanks for your help in advance.

Not sure why it is added but to get rid of it you can add a space to the beginning of the excerpt.

Edit: I should read the rest of the posts first!

Last edited by graeme (2009-04-06 15:56:51)

Offline

#6 2009-04-06 19:18:13

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: How to remove <p> tags on excerpt

Try to replace <txp:excerpt /> in your page/form with this code:

<txp:php>echo parse(str_replace(array("<p>", "</p>") , "" , $GLOBALS['thisarticle']['excerpt']));</txp:php>

Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#7 2009-04-06 23:36:12

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Re: How to remove <p> tags on excerpt

Put a space before your img code in the excerpt field…

[put a space here]!/test/images/roman_thumb.gif!

Last edited by qrayg (2009-04-06 23:36:24)

Offline

#8 2009-04-07 04:23:49

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

Re: How to remove <p> tags on excerpt

It is because Textile is run on the excerpt. Turn Textile off for excerpts on your article (look under the Advanced Options) and you don’t have to escape it (using a space or notextile).

Offline

#9 2011-01-19 18:57:14

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: How to remove <p> tags on excerpt

Mary wrote:

It is because Textile is run on the excerpt. Turn Textile off for excerpts on your article (look under the Advanced Options) and you don’t have to escape it (using a space or notextile).

I was just looking for the answer! Got it and it is so simple! Thanx.

Offline

Board footer

Powered by FluxBB