user882670
user882670

Reputation:

Joomla Get Page Id

I'm trying to get the current page_id, user_id and date from a Joomla 2.5.14. This is the code I'm using:

<?php
$foo = $jinput->get('id');
echo $foo;


$user =& JFactory::getUser();
$usr_id = $user->get('id');
echo $usr_id;

$date =& JFactory::getDate();
echo 'Current date and time is: ' . $date->toFormat() . "\n";

?>

JFactory is working ok (I get the current user and date) but jinput is giving the error:

Notice: Undefined variable: jinput in`

Upvotes: 3

Views: 8594

Answers (1)

Lodder
Lodder

Reputation: 19733

You forgot to define $jinput:

<?php
$jinput = JFactory::getApplication()->input;

$foo = $jinput->get('id');
echo $foo;

$user = JFactory::getUser();
$usr_id = $user->get('id');
echo $usr_id;

$date = JFactory::getDate();
echo 'Current date and time is: ' . $date->toFormat() . "\n";

?>

On a side note, you don't need to use &.

Hope this helps

Upvotes: 7

Related Questions