I've looked through the discussions but can't find a solution to my problem, or at least one that I can grok.
I've been making a number of accessibility improvements to the default theme, mostly by extending various views. Now I'm trying to improve some of the menu items that are created, such as the bookmark and rss links in the sidebar, and the delete and likes links on items in the wire.
For instance, the default bookmarks link in the sidebar has the following structure:
<a rel="nofollow" title="Bookmark this page" href="http://my.site/bookmarks/add/35?address=http%3A%2F%2Fmy.site%2Fthewire%2Fall"><span class="elgg-icon elgg-icon-push-pin-alt "></span></a>
The link has no content, so is meaningless to someone using a screen reader. What I'd like to do is add a <span> with some meaningful link text that I can position offscreen with CSS, for example:
<a rel="nofollow" title="Bookmark this page" href="http://my.site/bookmarks/add/35?address=http%3A%2F%2Fmy.site%2Fthewire%2Fall"><span class="offscreen">Bookmark this page</span><span class="elgg-icon elgg-icon-push-pin-alt "></span></a>
It's not clear to me if I can do this by extending some view in the Bookmarks plugin, or if I need to write an additional plugin, e.g., to unregister the menu item and then register a custom menu item. I would hope that I could do this by simply extending the appropriate view, but can't figure that out. Same thing goes for the delete and like menu items on wire posts, blog posts, and other objects.
Any advice?
Thanks!
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Matt Beckett@Beck24

Matt Beckett - 0 likes
- Kek@kekola

Kek - 0 likes
- Matt Beckett@Beck24

Matt Beckett - 0 likes
- Kek@kekola

Kek - 0 likes
You must log in to post replies.http://docs.elgg.org/wiki/Menus
http://blog.elgg.org/pg/blog/cash/read/171/elggs-new-menu-system-registering-a-menu-item
http://community.elgg.org/discussion/view/1033800/intercept-topbar-menu-items
Thanks, Matt. I had looked at those pages, but was struggling to understand them. So I took your linking to them as a prod to try harder :)
Not sure if what I've done is the best way to go about it, but below is my default theme extension's start.php. Right or wrong, it has the effect I'm after.
Cheers for the prod.
<?php
elgg_register_event_handler('init', 'system', 'cop_init');
function cop_init() {
elgg_register_plugin_hook_handler('register', 'menu:extras', 'modify_extras_menu');
elgg_register_plugin_hook_handler('register', 'menu:entity', 'modify_wire_entity_menu');
elgg_register_plugin_hook_handler('register', 'menu:river', 'modify_river_menu');
elgg_register_plugin_hook_handler('register', 'menu:widget', 'modify_widget_menu');
elgg_register_plugin_hook_handler('register', 'menu:annotation', 'modify_annotation_menu');
elgg_register_plugin_hook_handler('register', 'menu:topbar', 'modify_topbar_menu');
}
function modify_extras_menu($hook, $type, $value, $params) {
foreach ($value as $k => $v) {
if ($v->getName() == 'bookmark') {
$v->setText('<span class="visually-hidden">' . elgg_echo('bookmarks:this') . '</span>' . elgg_view_icon('push-pin-alt'));
}
if ($v->getName() == 'rss') {
$v->setText('<span class="visually-hidden">' . elgg_echo('feed:rss') . '</span>' . elgg_view_icon('rss'));
}
}
return $value;
}
function modify_wire_entity_menu($hook, $type, $value, $params) {
foreach ($value as $k => $v) {
if ($v->getName() == 'delete') {
$v->setText('<span class="visually-hidden">' . elgg_echo('delete') . '</span>' . elgg_view_icon('delete'));
}
}
return $value;
}
function modify_river_menu($hook, $type, $value, $params) {
foreach ($value as $k => $v) {
if ($v->getName() == 'delete') {
$v->setText('<span class="visually-hidden">' . elgg_echo('delete') . '</span>' . elgg_view_icon('delete'));
}
}
return $value;
}
function modify_widget_menu($hook, $type, $value, $params) {
foreach ($value as $k => $v) {
if ($v->getName() == 'collapse') {
$v->setText('<span class="visually-hidden">Toggle collapsed</span>');
}
if ($v->getName() == 'delete') {
$v->setText('<span class="visually-hidden">' . elgg_echo('widget:delete', array($params['entity']->getTitle())) . '</span>' . elgg_view_icon('delete-alt'));
}
if ($v->getName() == 'settings') {
$v->setText('<span class="visually-hidden">' . elgg_echo('widget:edit') . '</span>' . elgg_view_icon('settings-alt'));
}
}
return $value;
}
function modify_annotation_menu($hook, $type, $value, $params) {
foreach ($value as $k => $v) {
if ($v->getName() == 'delete') {
$v->setText('<span class="visually-hidden">' . elgg_echo('delete') . '</span><span class="elgg-icon elgg-icon-delete"></span>');
}
}
return $value;
}
function modify_topbar_menu($hook, $type, $value, $params) {
foreach ($value as $k => $v) {
if ($v->getName() == 'elgg_logo') {
$logo_url = elgg_get_site_url() . "_graphics/elgg_toolbar_logo.gif";
$v->setText('<img src="'.$logo_url.'" alt="Elgg" width="38" height="20">');
}
if ($v->getName() == 'profile') {
$viewer = elgg_get_logged_in_user_entity();
$v->setText(elgg_view('output/img', array(
'src' => $viewer->getIconURL('topbar'),
'alt' => 'My profile',
'title' => 'My profile',
'class' => 'elgg-border-plain elgg-transition',
)));
}
if ($v->getName() == 'friends') {
$v->setText('<span class="visually-hidden">My friends</span>' . elgg_view_icon('users'));
$v->setTooltip('My friends');
}
if ($v->getName() == 'messages') {
$v->setText('<span class="visually-hidden">My messages</span>' . elgg_view_icon('mail'));
$v->setTooltip('My messages');
}
}
return $value;
}
?>
Oh, man, I feel like crying!
I wish everyone would take prods as well as you :)
For the record, that's exactly the answer. Well done!
Yay! Prods and props :)