drupal 7 删除样式标签表单 rss 视图字段
drupal 7 remove style tag form rss view field
我有两个视图,基本上它们在做同样的事情(列出节点的内容)。但是一个是在页面上显示内容,另一个是在 rss 文件上导出相同的内容。问题是一个名为 "description" 的字段是一个文本,用户可以添加一些样式,因此它可能包含 css 标签“”。在第一个视图上显示样式绝对没问题,尽管 rss 视图会在描述字段内容中导出“....”标签。并且应该从 rss 文件中删除此样式标签。我曾尝试使用管理界面去除 html 标签,但它不起作用,我将描述字段模板作为主题并使用 reg_replace 删除样式标签,但它也不起作用,所以我有试图遍历内容并删除样式标签。但是 Drupal 输出错误 "limit execution",因为字段内容太多(我可以增加本地的执行时间并且有效,但不推荐在生产环境中使用)。因为字段内容可以包含很长的文本项,是否有其他方法可以从 rss 视图中删除样式标签?
// views-view-field--VIEWNAME-feed--views-data-export-1--field-th-paragraphs.tpl.php
<?php
// get position of styling tag
$pos = strpos($output, 'text/css');
$endpos = strpos($output, '</style>');
// iterate at least one time to remove css
do
{
// check if description has css tag
if($pos > 0)
{
// the closing tag of the css maybe cut off
if($endpos > 0)
$length = $endpos - $pos;
else
$length = $endpos - strlen($newoutput);
// repeat process until removing all css tags
$newoutput = substr_replace($newoutput, '', ($pos - 13), ($length
+ 20));
$pos = strpos($newoutput, 'text/css');
$endpos = strpos($newoutput, '</style>');
}
else{
print $output;
}
}
while( $pos > 0);
print($output);
?>
打开您的视图,转到字段设置,在重写结果下,您有一个选项:去除 HTML 标签
我有两个视图,基本上它们在做同样的事情(列出节点的内容)。但是一个是在页面上显示内容,另一个是在 rss 文件上导出相同的内容。问题是一个名为 "description" 的字段是一个文本,用户可以添加一些样式,因此它可能包含 css 标签“”。在第一个视图上显示样式绝对没问题,尽管 rss 视图会在描述字段内容中导出“....”标签。并且应该从 rss 文件中删除此样式标签。我曾尝试使用管理界面去除 html 标签,但它不起作用,我将描述字段模板作为主题并使用 reg_replace 删除样式标签,但它也不起作用,所以我有试图遍历内容并删除样式标签。但是 Drupal 输出错误 "limit execution",因为字段内容太多(我可以增加本地的执行时间并且有效,但不推荐在生产环境中使用)。因为字段内容可以包含很长的文本项,是否有其他方法可以从 rss 视图中删除样式标签?
// views-view-field--VIEWNAME-feed--views-data-export-1--field-th-paragraphs.tpl.php
<?php
// get position of styling tag
$pos = strpos($output, 'text/css');
$endpos = strpos($output, '</style>');
// iterate at least one time to remove css
do
{
// check if description has css tag
if($pos > 0)
{
// the closing tag of the css maybe cut off
if($endpos > 0)
$length = $endpos - $pos;
else
$length = $endpos - strlen($newoutput);
// repeat process until removing all css tags
$newoutput = substr_replace($newoutput, '', ($pos - 13), ($length
+ 20));
$pos = strpos($newoutput, 'text/css');
$endpos = strpos($newoutput, '</style>');
}
else{
print $output;
}
}
while( $pos > 0);
print($output);
?>
打开您的视图,转到字段设置,在重写结果下,您有一个选项:去除 HTML 标签