Forum Moderators: coopster
//Construct an unordered list from $navlinks
//Accessibility: heading hidden from visual browsers by default.
$navigation = get_accesshide(get_string('youarehere','access'), 'h2')." <ul>\n";
$lastindex = count($navlinks) - 1;
$i = -1; // Used to count the times, so we know when we get to the last item.
$first = true;
foreach ($navlinks as $navlink) {
$i++;
$last = ($i == $lastindex);
if (!is_array($navlink)) {
continue;
}
if (!empty($navlink['type']) && $navlink['type'] == 'activity' && !$last && $hideactivitylink) {
continue;
}
$navigation .= '<li class="first">';
if (!$first) {
$navigation .= get_separator();
}
if ((!empty($navlink['link'])) && !$last) {
$navigation .= "<a onclick=\"this.target='$CFG->framename'\" href=\"{$navlink['link']}\">";
}
$navigation .= "{$navlink['name']}";
if ((!empty($navlink['link'])) && !$last) {
$navigation .= "</a>";
}
$navigation .= "</li>";
$first = false;
}
$navigation .= "</ul>";
return(array('newnav' => true, 'navlinks' => $navigation));
}
Output:
<ul>
<li class="first">Home</li>
<li class="first">Course</li>
<li class="first">Activity</li>
</ul>
But i want this:
<ul id="nav">
<li class="navtop">Home</li>
<li class="navitem"><a href="http://www.google.com">Course</a></li>
<li class="navitem"><a href="http://www.msn.com">Activity</a></li>
<li class="navitem"><a href="http://">Web Page</a></li>
</ul>
I've alread done: Added a class=nav to the <ul>
$navigation = get_accesshide(get_string('youarehere','access'), 'h2')." <ul class=nav>\n";
Now i need to output the first link with class=navtop
Any ideas?
[edited by: eelixduppy at 9:33 pm (utc) on Jan. 12, 2009]
[edit reason] snipped url [/edit]
//Construct an unordered list from $navlinks
//Accessibility: heading hidden from visual browsers by default.
$navigation = get_accesshide(get_string('youarehere','access'), 'h2')." <ul>\n";
$lastindex = count($navlinks) - 1;
$i = -1; // Used to count the times, so we know when we get to the last item.
$first = true;
foreach ($navlinks as $navlink) {
$i++;
$last = ($i == $lastindex);
if (!is_array($navlink)) {
continue;
}
if (!empty($navlink['type']) && $navlink['type'] == 'activity' && !$last && $hideactivitylink) {
continue;
}
$navigation .= '<li class="first">';
if (!$first) {
$navigation .= get_separator();
}
if ((!empty($navlink['link'])) && !$last) {
$navigation .= "<a onclick=\"this.target='$CFG->framename'\" href=\"{$navlink['link']}\">";
}
$navigation .= "{$navlink['name']}";
if ((!empty($navlink['link'])) && !$last) {
$navigation .= "</a>";
}
$navigation .= "</li>";
$first = false;
}
$navigation .= "</ul>";
return(array('newnav' => true, 'navlinks' => $navigation));
}
As posted in the first post.