Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » Access Keys

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

Page: 1 2
Go to End
Author Topic: 1343 Views
  • Big Bang Creative
    Avatar
    Community Member
    92 Posts

    Access Keys Link to this post

    Is there a way to add access keys?

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: Access Keys Link to this post

    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
    Avatar
    Community Member
    92 Posts

    Re: Access Keys Link to this post

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

  • Big Bang Creative
    Avatar
    Community Member
    92 Posts

    Re: Access Keys Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: Access Keys Link to this post

    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
    Avatar
    Community Member
    92 Posts

    Re: Access Keys Link to this post

    Brilliant, I will have to give this a go!

    Thanks.

  • elgordo
    Avatar
    Community Member
    70 Posts

    Re: Access Keys Link to this post

    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

  • elgordo
    Avatar
    Community Member
    70 Posts

    Re: Access Keys Link to this post

    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

    1343 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.