Is there a way to add access keys?
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
- Page 11(current)
- 2
- Next 10 entries
We have done this on 1 project, all we did was make another 1 line txt field in the CMS for the access key then in the <% control Menu %> or <% control Children %> calls we just did <a href="$Link" <% if AccessKey %>accesskey="$AccessKey"<% end_if %>> and then you can set the accesskey in the cms
How do I add in one line into the CMS then?
I think it would be a good idea to add in another tab called "Accessibility" and add the new "Access Key" field to that. Can this be done?
Sure, In your mysite/code/Page.php file you need to add a database field for it so add an entry to the static $db array
static $db = array(
.. whatever else
'AccessKey' => 'Varchar(1)'
);
Then add a tab and field to the cms but adding a line to the getCMSFields() function in that same file
function getCMSFields() {
$fields = parent::getCMSFields();
.. whatever else
$fields->addFieldToTab('Root.Content.Accessibility', new TextField('AccessKey'));
return $fields;
}
Then in your templates just use $AccessKey where ever you output pages.
Brilliant, I will have to give this a go!
Thanks.
Minor addition to this example, namely set the length of the text field to 1
$tf = new TextField('AccessKey');
$tf->setMaxLength(1);
$fields->addFieldToTab('Root.Content.Accessibility', $tf);
Cheers,
Gordon
hi
I've created a module (for Silverstripe 2.4 currently, will upgrade to 3 at some point) to encompass access key functionality:
- Adds an access key tab to every page in the CMS editor, where an access key can be optionally set
- Adds an Include template to render the access keys in your HTML
- Adds an accessibility information page that displays the access keys in readable form for reference
- Adds an accessibility tab to the Site Configuration in the CMS with option of configuring the 'Skip to Navigation' access key
More information can be found at http://weboftalent.asia/blog/access-keys-module/
Cheers
Gordon
- Page 11(current)
- 2
- Next 10 entries