FORUMS CLOSED DUE TO SPAM. YOU STILL CAN ADD POST!

Access keys for nav / menu?

Feed 7 posts, 3 voices

Avatar
15 posts

Hi,

Is it possible to set access keys, (accessibility) , to the menu code in frog cms?

Andy said that “If you check out this link you will see the link() function allows options to be passed to it. I don’t know whether access keys can be one of them?”

Any help with this would be greatly, no, hugely appreciated : )

 
Avatar
5 posts

Have you check the link() function code? Probably that you can use the options params to pass the accesskey=“x” parameter, or use it as an array link(null,array(accesskey => ‘x’));

 
Avatar
15 posts

Thanks ponsfrilus, don’t suppose you could provide an example pleasE?

 
Avatar
5 posts

This is the link() function

frog/app/class/Page.php :

public function link($label=null, $options='')
{
if ($label == null)
$label = $this->title();
return sprintf('<a href="%s" %s>%s</a>',
$this->url(),
$options,
$label
);
}

So use

var_dump($this->link($label='asd', $options='accesskey="h" target="_blank"'));
print $this->link($label='asd', $options='accesskey="h" target="_blank"');

++

 
Avatar
15 posts

Many thanks ponsfrilus, I will give it a go sometime tomorrow and let you know how i ge on.

 
Avatar
15 posts

Not quite sure I’m supposed to implement this into my nav/menu code.

<div id="menu" class="jqueryslidemenu">
<ul>
<li><a<?php echo url_match('/') ? ' class="current"': ''; ?> href="<?php echo URL_PUBLIC; ?>">Home</a></li>
<?php
$menu = $this->find('/')->children();
foreach ($menu as $child) {
    echo '<li>';
if ($child->children()) {
    echo $child->link($child->title, (in_array($child->slug, explode('/', $this->url)) ? ' class="current"': null));
    echo PHP_EOL . '<ul>';
	if ($child->slug == 'news') { // limit news listing
	foreach ($child->children(array('limit' => 5, 'order' => 'created_on DESC')) as $kids) {
	echo '<li>' . $kids->link($kids->title, (in_array($kids->slug, explode('/', $this->url)) ? ' class="sub-current"': null)) . '</li>'  . PHP_EOL;
	}
	echo '</ul>' . PHP_EOL;
	} else { // non-archives
        foreach($child->children() as $kids) {
		     {
			// all the rest
			echo '<li>' . $kids->link($kids->title, (in_array($kids->slug, explode('/', $this->url)) ? 'class="sub-current"': null)) . '</li>'  . PHP_EOL;
			}
        } // end kids foreach
        echo '</ul>' . PHP_EOL;
	} // end non-archives else	
    } else {  // end child-children if
    echo $child->link($child->title, (url_start_with($child->url) ? ' class="current"': null));
    } // end else
    echo '</li>' . PHP_EOL;
} // end child-foreach
?>
</ul>
<br style="clear: left" />
</div>

Any ideas?

 
Avatar
15 posts

I have managed to get part of it working… (Why aren’t the block code boxes working?) [leave a space!]

<div id="menu" class="jqueryslidemenu">
<ul>
<li><a<?php echo url_match('/') ? ' class="current"': ''; ?> href="<?php echo URL_PUBLIC; ?>" accesskey="1">Home</a></li>
<?php
$menu = $this->find('/')->children();
foreach ($menu as $child) {
    echo '<li>';
if ($child->children()) {
    echo $child->link($child->title, (in_array($child->slug, explode('/', $this->url)) ? ' class="current"': null));		

    echo PHP_EOL . '<ul>';
	if ($child->slug == 'news-events') { // limit news listing
	foreach ($child->children(array('limit' => 5, 'order' => 'created_on DESC')) as $kids) {
	echo '<li>' . $kids->link($kids->title, (in_array($kids->slug, explode('/', $this->url)) ? ' class="sub-current"': null)) . '</li>'  . PHP_EOL;
	}
	echo '</ul>' . PHP_EOL;
	} else { // non-archives
        foreach($child->children() as $kids) {
		     {
			// all the rest
			echo '<li>' . $kids->link($kids->title, (in_array($kids->slug, explode('/', $this->url)) ? 'class="sub-current"': null)) . '</li>'  . PHP_EOL;
			}
        } // end kids foreach
        echo '</ul>' . PHP_EOL;
	} // end non-archives else	
    } 		
	elseif ($child->slug == 'example1') {  // end child-children if
    echo $child->link($child->title, (url_start_with($child->url) ? ' class="current" ': null).$options='accesskey="I"');    
    } // end elseif	
	elseif ($child->slug == 'example2') {  // end child-children if
    echo $child->link($child->title, (url_start_with($child->url) ? ' class="current" ': null).$options='accesskey="A"');    
    } // end elseif	
	elseif ($child->slug == 'example3') {  // end child-children if
    echo $child->link($child->title, (url_start_with($child->url) ? ' class="current" ': null).$options='accesskey="9"');    
    } // end elseif	
	else {  // end child-children if
    echo $child->link($child->title, (url_start_with($child->url) ? ' class="current" ': null));    
    } // end else	
    echo '</li>' . PHP_EOL;
} // end child-foreach
?>
</ul>
<br style="clear: left" />
</div>

I just need to get it working on the line below with ($child->slug == ‘example4’)…

echo $child->link($child->title, (in_array($child->slug, explode('/', $this->url)) ? ' class="current"': null));
 
Avatar
26 posts

This is what I use, edit to your need:

<div id="menu">
<ul>
<li<?php echo url_match('/') ? ' id="current"': null; ?>><a href="<?php echo URL_PUBLIC; ?>" accesskey="1">Home</a></li>
<?php foreach($this->find('/')->children() as $menu): ?>
<?php
// pages to omit from navigation
$omit_array = array('news', 'secret');
if (in_array($menu->slug, $omit_array)) {
    continue;
}
?>
<li<?php echo (url_start_with($menu->url)) ? ' id="current"': null; ?>>
<?php
// accesskey's for your page by slugname
if ($menu->slug == 'test') { echo $menu->link($menu->title, (url_start_with($menu->url) ? 'id="current"': null).$options='accesskey="2"');  }
elseif ($menu->slug == 'stories') { echo $menu->link($menu->title, (url_start_with($menu->url) ? 'id="current"': null).$options='accesskey="3"');
} else {
?>
<?php echo $menu->link() . PHP_EOL; } ?></li>
<?php endforeach; ?></ul>
</div>