Open aggregator links in a new tab
Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites
Most popular browsers today allow the user to keep multiple tabs open. To take advantage of this feature and open links in a separate tab, you can either look at the External Link module, override the HTML in the aggregator module, or override the code in your theme's template.php.
Overriding in the Aggregator Module
Find the HTML to override
You'll need to edit the HTML in one or more of the following files:
aggregator-item.tpl.php: External links from the /aggregator page.
aggregator-summary-items.tpl.php: Feed source links from the /aggregator page.
aggregator-summary-item.tpl.php: External links from the /aggregator/sources page.
aggregator-feed-source.tpl.php: Feed source links from the /aggregator/sources page.
Find the line containing this text:
<a href="<?php print $source_url; ?>">
After the closing quotation mark but before the closing brace, add the text target="_blank". The resulting code will look like this:
<a href="<?php print $source_url; ?>" target="_blank">
With a Template.php function
function MY_THEME_aggregator_block_item($variables) {
$link = check_url($variables['item']->link);
$title = check_plain($variables['item']->title);
// I prefer sprintf to string concatenation.
return sprintf('%s',
$link,
$title);
}
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion