Skip to content

Commit

Permalink
Issue #25: Add an alter hook for renderable output.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jen Lampton committed Jan 16, 2018
1 parent 60f3d9d commit ae4f9db
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions on_the_web.api.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,24 @@ function hook_on_the_web_get_services_alter(&$services) {
'fa-icon' => 'fa-vimeo-square',
);
}

/**
* Alter the links displayedby on_the_web_display_block().
*
* This alter function can be used to:
* - Change how the links are rendered.
*
* @see on_the_web_display_block().
*/
function hook_on_the_web_links_alter(&$links) {
// Turn the links into an item-list.
$items = array();
foreach ($links as $link) {
$items[] = backdrop_render($link);
}
$links = array(
'#theme' => 'item_list',
'#items' => $items,
);
}

5 changes: 4 additions & 1 deletion on_the_web.module
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ function on_the_web_display_block($delta, $settings = array(), $contexts = array
}
}

// Add an alter here.
backdrop_alter('on_the_web_links', $links);

return backdrop_render($links);
}

Expand Down Expand Up @@ -290,7 +293,7 @@ function on_the_web_get_services() {
'fa-icon' => 'fa-linkedin-square',
),
'itunes' => array(
'name' => 'iTunes',
'name' => 'Podcast',
'fa-icon' => 'fa-apple',
),
'delicious' => array(
Expand Down

0 comments on commit ae4f9db

Please sign in to comment.