简体   繁体   中英

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`

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM