欢迎各位兄弟 发布技术文章
这里的技术是共享的
1) 先在后台进行截取的处理
2) 移除图像等标签
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;
}
/**
* Override or insert variables into the node template.
*/
function bartik_clone_preprocess_node(&$variables) {
if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
$variables['classes_array'][] = 'node-full';
}
if(isset($variables['content']['body'][0]['#markup']) && $variables['teaser']){
$variables['content']['body'][0]['#markup'] = _strip_only($variables['content']['body'][0]['#markup'], '<img><iframe><embed><br>');
}
// var_dump($variables['field_accepter']);
}