recoInrelax
recoInrelax

Reputation: 707

Joomla php how to check if user is viewing specific page

I want to add a facebook plugin to a specific joomla page. To check if the user is viewing the homepage i use the following:

<?php
$menu = JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
    echo 'This is the front page';
}
?>

I don't know how this code works, but i think the 'getDefault() method return me the homepage url. Now i want to do the same, not for the frontPage but for a specific page, lets say:

www.myDomain.com/contactos

How can i accomplish that?

Upvotes: 2

Views: 5498

Answers (2)

Vassilis Pits
Vassilis Pits

Reputation: 3848

Try this, it works for me:

$currentMenuName = JSite::getMenu()->getActive()->name ;

Upvotes: 0

Rikesh
Rikesh

Reputation: 26451

You an get current menu_id & menu_name respectively like this:

$currentMenuId = JSite::getMenu()->getActive()->id ;

$currentMenuName = JSite::getMenu()->getActive()->name ;

Upvotes: 4

Related Questions