【问题标题】:How can I remove quotes in rss如何删除 rss 中的引号
【发布时间】:2014-07-08 15:35:07
【问题描述】:

我的 RSS 提要中有这个,在 drupal 视图中:

<link>Prueba &quot;con comillas&quot;</link>

我尝试过创建这样的模块:

function views_without_encoded_preprocess_views_view_views_rss(&$vars) {
  if (!empty($vars['rss_feed'])) {
    $vars['rss_feed'] = strtr($vars['rss_feed'], array(
      '&amp;#039;' => '&#039;',
      '&amp;quot;' => '&quot;',
      '&amp;lt;' => '&lt;',
      '&amp;gt;' => '&gt;',
      '&amp;amp;' => '&amp;',
      '&quot;gt' => '',
    ));
  }
}

但一切都不好。我继续看到这部分:

<link>Prueba &quot;con comillas&quot;</link>

仅用于引号。

【问题讨论】:

    标签: html drupal rss quotes


    【解决方案1】:

    我看到你尝试使用 Views RSS。

    有一个似乎有效的修复程序,但它仅在 Drupal 6 站点上进行了测试。在 Drupal 7 中,一些事情发生了变化,但试试这个:

    转到 views_rss/theme 并打开 theme.inc

    复制整个 'function template_preprocess_views_view_views_rss 函数,并将其放入主题的 template.php 中。

    将函数名称更改为:function yourthemename_precrocess_views_view_views_rss

    然后在原始主题中的第 200 行,或者它读取“// 将 XML 元素添加到项目数组”的地方插入以下内容:

    if (empty($rss_elements)) continue;
           // Insert here -- clean up special characters
           $rss_elements[0]['value'] = htmlspecialchars_decode(trim(strip_tags(decode_entities( $rss_elements[0]['value'])),"\n\t\r\v\0\x0B\xC2\xA0 "));
           $rss_elements[0]['value'] = htmlspecialchars($rss_elements[0]['value'], ENT_COMPAT);
           // end of cleaning
           // Add XML element(s) to the item array.
           $rss_item['value'] = array_merge($rss_item['value'], $rss_elements);
    }
    

    检查您的 RSS....您可能需要刷新缓存几次。

    您可以尝试的另一件事是htmlspecialchars。在我看来,Views RSS 字段的输出可以使用它来强制对引号、撇号和 & 符号进行编码。

    希望对您有所帮助。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-21
    • 2021-06-30
    • 1970-01-01
    相关资源
    最近更新 更多