5

I've tried using hook_preprocess_node() inside of a if statement for arg(0) == 'taxonomy', but changes to the node aren't carried through to display.

What is the best way to make the teasers appear in plain text (stripped HTML) when listing in the taxonomy node listing page?

1 Answer 1

6

Within node--taxonomy.tpl.php, you could isolate the field data for your teaser or any field, depending on how you have that template set up, and apply the php strip_tags to that field data.

For example:

$teaser = render($content['body'][0]);
$textteaser = strip_tags($teaser);

This video is a great starting point for learning about the theming templates if that is new: Theming Fields and Nodes with Templates


One other idea is to isolate the div that wraps each teaser (if possible) and use jQuery to transform the content using the relevant CSS selector using .text() method.

3
  • I was really looking for the best place to find the teaser. Thanks.
    – Justin
    Jan 8, 2012 at 18:03
  • I assumed you weren't supposed to put any logic in the tpl files, but I guess this is the only method here.
    – Justin
    Jan 11, 2012 at 16:56
  • I'm sure there is another method. I wish I knew it, this is just the only way i would know how to go about it...
    – Starfs
    Jan 25, 2012 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.