Active
Project:
Shortcode
Version:
7.x-2.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
15 Jul 2012 at 11:38 UTC
Updated:
15 Jul 2012 at 11:40 UTC
Using the strip_tags function on node teaser in preprocess_node file I can remove the shortcodes from node teasers.
If I want to remove only the shortcode and no the other tags I should do something like this http://drupal.org/node/659458#comment-6035146
Could anyone help me to change the strip only function to support shortcodes ?
<?php
/* Strip only selcted tags in THEME_preprocess_node function below */
function strip_only($str, $tags) {
if(!is_array($tags)) {
$tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
if(end($tags) == '') array_pop($tags);
}
foreach($tags as $tag) $str = preg_replace('#</?'.$tag.'[^>]*>#is', '', $str);
return $str;
}
/* Strip only selected tags from teasers - in this case, embed and iframe */
function YOUR_THEME_preprocess_node(&$vars) {
if(isset($vars['content']['body'][0]['#markup']) && $vars['teaser']) {
$vars['content']['body'][0]['#markup'] = strip_only($vars['content']['body'][0]['#markup'], '<iframe> <embed>');
}
}
?>
Thanks
Comments
Comment #1
manos_ws commented!!!! shortcode not Shortdoce