Help removing a link with hook_link_alter in Drupal
I need some help with the syntax of hook_link_alter . My code is
function modulename_link_alter(&$links, &$no开发者_如何学Cde, $comment = null){
foreach($links as $module=>$link){
if (isset($links['link_id'])) {
unset($links['link_id']);
}
}
}
This does not remove the link.
Try
function mymodule_link_alter(&$links, $node) {
foreach ($links as $module => $link) {
if (strstr($module, 'blog')) {
unset($links[$module]);
}
}
}
Replace blog
with where ever you need it to remove
It can be very simple, put this in a custom module. It is good practice to have your own module dedicated to site tweaks.
function mycustomsitemodule_link_alter(&links, $node) {
unset($links['link_id_to_unset']);
}
Bare minimum needed to get rid of a link.
精彩评论