Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Access Keys

Go to End

9 Posts   1340 Views

Big Bang Creative

27 February 2009 at 5:02am Community Member, 92 Posts

Is there a way to add access keys?


27 February 2009 at 3:00pm Forum Moderator, 5511 Posts

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

Big Bang Creative

27 February 2009 at 10:23pm Community Member, 92 Posts

How do I add in one line into the CMS then?

Big Bang Creative

27 February 2009 at 10:29pm (Last edited: 27 February 2009 10:30pm), Community Member, 92 Posts

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?


28 February 2009 at 2:12pm Forum Moderator, 5511 Posts

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.

Big Bang Creative

3 March 2009 at 12:43am Community Member, 92 Posts

Brilliant, I will have to give this a go!



19 April 2011 at 7:05pm Community Member, 70 Posts

Minor addition to this example, namely set the length of the text field to 1

$tf = new TextField('AccessKey');
$fields->addFieldToTab('Root.Content.Accessibility', $tf);




16 November 2012 at 11:50pm Community Member, 70 Posts


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



Go to Top