Hello Mike,
As i stated already; no I did not test it.
But I'm sorry, I did not read your question good and did not realise
that 'rel="nofollow"' is an attribute on an anchor and not on a link tag.
I think the solution for you would be to create a view helper
(I'm assuming here you need the menu navigation helper and extend it
here, if i'm assuming wrong, you'll get the idea :))
/**
* Menu
* Extends Zend_View_Helper_Navigation_Menu to add support for
rel="nofollow"
* attribute on anchors.
*
* @category Application
* @package Application
* @subpackage View_Helper
* @license http://framework.zend.com/license BSD License
* @author Maghiel Dijksman <[email protected]>
* @version 1.0.0 - 03-mar-2010
*/
class Application_View_Helper_Menu
extends Zend_View_Helper_Navigation_Menu
{
/**
* Returns an HTML string containing an 'a' element for the given
page if
* the page's href is not empty, and a 'span' element if it is empty
*
* Overrides {...@link Zend_View_Helper_Navigation_Abstract::htmlify()}.
*
* @param Zend_Navigation_Page $page page to generate HTML for
* @return string HTML string for the given page
*/
public function htmlify(Zend_Navigation_Page $page)
{
// get label and title for translating
$label = $page->getLabel();
$title = $page->getTitle();
// translate label and title?
if ($this->getUseTranslator() && $t = $this->getTranslator()) {
if (is_string($label) && !empty($label)) {
$label = $t->translate($label);
}
if (is_string($title) && !empty($title)) {
$title = $t->translate($title);
}
}
// get attribs for element
$attribs = array(
'id' => $page->getId(),
'title' => $title,
'class' => $page->getClass()
);
// Check if there is a 'nofollow' relation
if (true === $page->get('no-follow')) {
$attribs['rel'] = 'nofollow';
}
// does page have a href?
if ($href = $page->getHref()) {
$element = 'a';
$attribs['href'] = $href;
$attribs['target'] = $page->getTarget();
} else {
$element = 'span';
}
return '<' . $element . $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($label)
. '</' . $element . '>';
}
} // end class
In you controller:
$page = new Zend_Navigation_Page_Uri(array(
'label' => 'My Website',
'uri' => 'http://example.com',
'no-follow' => true
));
$container = new Zend_Navigation();
$container->addPage($page);
$this->view->getHelper('menu')->setContainer($container);
And yes, I did test this :p
On 25-2-2010 0:45, Iron_Mike wrote:
Maghiel,
besides that the syntax was incorrect, both of your example do NOT work.
Did you test it ?
Thanx for your help.
- M