Angularjs developer
Angularjs developer

Reputation: 241

how to get specific menu items in joomla 2.5?

I have a main menu. Each menu item is link to an article.

Now on the complete site there are many places in the components and modules where I need to show two links : Privacy Policy & Portfolio.

Can someone please guide me? I do not want to hard code the links as the item id would differ in production.

Upvotes: 1

Views: 520

Answers (2)

Bhavik Mulia
Bhavik Mulia

Reputation: 160

try with this

<?php

$menuitemid = JRequest::getInt( 'Itemid' );
if ($menuitemid)
{
    $menu = JSite::getMenu();
    $menuparams = $menu->getParams( $menuitemid );
    $params->merge( $menuparams );
}

$propvalue= $params->get('property_name');

?>

Upvotes: -1

Lodder
Lodder

Reputation: 19743

You could use a database query like so:

<?php
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);         
    $query->select('*')
     ->from('#__menu')
     ->where('id = 435 OR id = 466');         
    $db->setQuery($query);
    $rows = $db->loadObjectList();

    foreach ($rows as $row) {
        echo '<a href="' . JRoute::_($row->link) . '">' . $row->title . '</a>';
    }
?>

Don't forget to change the ID's 435 and 466 to the ID's of your own menu items:

Hope this helps

Upvotes: 2

Related Questions