By brakai295 on
Hey there!
I'd like to know if/how it is possible to strip the HTML code out of teasers?
If, for instance, I have a hyperlink (or a bold, italic, whatever-tag) in the first few sentences and the sentence is cut, I end up with a really messy taxonomy page.
The piece of advice to use a break to control where the teaser is cut off doesn't help here.
Any idea?
thanks!
Comments
...
Maybe this one http://drupal.org/project/htmlcorrector
Not entirely sure it will work on teasers but it might.
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide
Not a solution (unfortunately)
MMh.. thanks a lot for your answer, but I don't think this will work. I'd need something that strips it out entirely and makes it plain text.
See, if I embedd a youtube video at the beginning of a node, the teaser would just be a huge mess! Even if this tool closed all tags. :-(
Anyone else any suggestions what I could do?
Webdesign Melbourne Australia
Work Travel Australien (Community with Drupal)
Reiseblog Community
node.tpl.php
add this code in node.tpl.php before print $content;
Kinda works...
Thanks KONG!
This kind of works. The only problem now is that the images linked to the nodes are not displayed anymore. You can have a look at my teaser list (with images) here: http://www.ausmag.de/australien-community/work-travel-artikel
Webdesign Melbourne Australia
Work Travel Australien (Community with Drupal)
Reiseblog Community - Sprachreisen, Auslandspraktikum, Arbeiten & Reisen
for better understanding of
for better understanding of stip_tags see http://www.php.net/strip_tags
what you need to do is use
strip_tags($content, '<img>');instead of stripping all tags
stripping html JUST in teaser (not full preview)
I tried this code however it strips the html from the full version in preview mode which is a bit disconcerting for users submitting content.
Is there any way to strip the html (or even just p/br line breaks) from teaser view? ie. the "preview trimmed version" and what ends up on the frontpage. It's fine for me if it stores this way in the node_revisions table (teaser cell) as I want the teaser views on the site to be stripped of line breaks.
It also means everything in preview is WYSIWYG in published node view and teaser views.
PS/Update: I'm not a programmer but I'm presuming the use of strip_tags where the node module writes the teaser value to the database table - or does this need to happen before it is written to the database (preview mode)? Can someone point me in the right direction - exactly where and how..? Thank you
If you have a different
If you have a different admin theme, just add that code to the front-end theme's template.php and you're done.
If not, add a check of the op parameter in your _phptemplate_vars():
I used that code above in my
I used that code above in my teaser section of Contemplate for that content type. Worked like a charm.
...
That's not very true. $page doesn't tell us whether it's teaser or full. It tells us that control on page was handed to the node so that is can change the title and breadcrumbs. To test for teaser, examine $teaser.
Use $teaser instead.