Skip to content

Instantly share code, notes, and snippets.

@mkorostoff
Created August 8, 2012 13:38
Show Gist options
  • Save mkorostoff/3295088 to your computer and use it in GitHub Desktop.
Save mkorostoff/3295088 to your computer and use it in GitHub Desktop.
<?php
function rsn_base_link(&$variables) {
//adds the rel attribute to lightbox2 links in order to fire the proper javascript
if (preg_match("/node\/\d*\/lightbox2/", $variables['path'])) {
//Looks up node type with views, much less expensive than node_load():
$type = get_view_results_with_arguments('rsn_articles', 'panel_pane_8', array(arg(1)));
$type = ($type[0]->node_type);
/*We'll transform these links everywhere except the media_gallery node page.
* We exclude the media_gallery page because, on those pages links of the format
* <a href="#slide-2"> fulfill the if() condition above
*/
if ($type != 'media_gallery') {
$variables['options']['attributes']['rel']='lightframe[|width:965px; height:758px;]';
}
}
return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment