【问题标题】:Drupal 7: change "read more" on content type teaserDrupal 7:更改内容类型预告片上的“阅读更多”
【发布时间】:2014-06-18 05:07:51
【问题描述】:

在内容类型的预告片中,如何更改“阅读更多”链接按钮的文本?

【问题讨论】:

    标签: drupal-7 teaser


    【解决方案1】:

    通过将此代码放在主题的 template.php 文件中覆盖节点输出(用您的主题名称和所需的阅读更多文本替换 YourThemeNameYourContentTypeNewReadMoreText)。

    Source

    <?php
    // Preprocess variables for node.tpl.php.
    function YourThemeName_preprocess_node(&$variables) {
      // Let's get that read more link out of the generated links variable!
      unset($variables['content']['links']['node']['#links']['node-readmore']);
    
      // Now let's put it back as it's own variable! So it's actually versatile!
      if ($variables['type'] == 'YourContentType') {
      $variables['newreadmore'] = t('<span class="YourContentTypereadmore"> <a href="!title">NewReadMoreText</a> </span>',
          array('!title' => $variables['node_url'],)
       );
      } else {
          $variables['newreadmore'] = t('<span class="newreadmore"> <a href="!title">Read More </a> </span>',
          array('!title' => $variables['node_url'],)
       );
      }
    
      $variables['title_attributes_array']['class'][] = 'node-title';
    }
    ?>
    

    【讨论】:

    • 这是基本修复。我所做的只是转到我的 www 目录和 grep -r “阅读更多”,对我来说它位于 modules/node/node.module 然后我制作了该文件的副本并将其更改为“加载更多”满足我的需要: if ($view_mode == 'teaser') { $node_title_stripped = strip_tags($node->title); $links['node-readmore'] = array('title' => t('Load more about @title', array('@title' => $ node_title_stripped)), 'href' => 'node/' . $node->nid, 'html' => TRUE, 'attributes' => array('rel' => 'tag', 'title' => $node_title_stripped ), ); }
    猜你喜欢
    • 2012-09-09
    • 1970-01-01
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    • 2020-09-23
    • 1970-01-01
    • 2013-09-05
    相关资源
    最近更新 更多