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.

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.

General Questions /

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

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

Access Keys


Go to End


9 Posts   2205 Views

Avatar
Big Bang Creative

Community Member, 92 Posts

27 February 2009 at 5:02am

Is there a way to add access keys?

Avatar
Willr

Forum Moderator, 5523 Posts

27 February 2009 at 3:00pm

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

Avatar
Big Bang Creative

Community Member, 92 Posts

27 February 2009 at 10:23pm

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

Avatar
Big Bang Creative

Community Member, 92 Posts

27 February 2009 at 10:29pm

Edited: 27/02/2009 10:30pm

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?

Avatar
Willr

Forum Moderator, 5523 Posts

28 February 2009 at 2:12pm

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.

Avatar
Big Bang Creative

Community Member, 92 Posts

3 March 2009 at 12:43am

Brilliant, I will have to give this a go!

Thanks.

Avatar
elgordo

Community Member, 70 Posts

19 April 2011 at 7:05pm

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

Avatar
elgordo

Community Member, 70 Posts

16 November 2012 at 11:50pm

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

Go to Top