Created
April 23, 2012 20:05
-
-
Save johnny5th/2473461 to your computer and use it in GitHub Desktop.
Drupal Anchor Links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<nav> | |
<ul> | |
<?php foreach ($items as $delta => $item): ?> | |
<li><?php print render($item); ?></li> | |
<?php endforeach; ?> | |
</ul> | |
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function TEMPLATE_preprocess_node(&$vars, $hook){ | |
for($i = 0; $i < sizeof($vars['content']['field_shortcuts']['#items']); $i++){ | |
if($vars['content']['field_shortcuts']['#items'][$i]['url'] == ""){ | |
$urldata = explode('#', $vars['content']['field_shortcuts']['#items'][$i]['display_url']); | |
if(isset($urldata[1])){ | |
$vars['content']['field_shortcuts'][$i]['#markup'] = '<a href="#' . $urldata[1] . '">' . $vars['content']['field_shortcuts'][$i]['#markup'] . '</a>'; | |
} | |
} | |
} | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment