简体   繁体   中英

Drupal-7 rss feed icon to text

I am looking for a way to modify the default Views feed icon from an image to a text value. I have found several cases where people change the default image to a new image, but I prefer working with fonts as they look more crisp regardless of resolution or device.

The idea is to replace the image with a FontAwesome icon (fa-rss-square, &#xf143). I have had succes with changing the default text in the search-block, ie.:

function theme_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'search_block_form') {
    $form['actions']['submit']['#value'] = decode_entities('');
  }
}

I am a newbie when it comes to php, so my attempts of modifying the hook explained in the Drupal-API has not worked (thus far):

function theme_feed_icon($variables) {
  $text = t('Subscribe to !feed-title', array('!feed-title' => $variables['title']));
  if ($image = theme('image', array('path' => 'misc/feed.png', 'width' => 16, 'height' => 16, 'alt' => $text))) {
    return l($image, $variables['url'], array('html' => TRUE, 'attributes' => array('class' => array('feed-icon'), 'title' => $text)));
  }
}

The current output looks like this:

<div class="feed-icon">
      <a href="mywebsite/news/rss" class="feed-icon" title="Subscribe to News from my website"><img typeof="foaf:Image" src="mywebsite/misc/feed.png" width="16" height="16" alt="Subscribe to news from my website"></a>
</div>

I'd like to keep the div and its class, but only have the font/text link inside, preferably without the same class. I'd appreciate any clever advice :-)

you could avoid printing the feed icon from php and just enter the html code either in the footer or the header of the view from the UI

or

you could hide the image via CSS, and use

.feed-icon:before {
font-family: FontAwesome;
content: "\f143";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM