Joomla Get Page Id(Joomla 获取页面 ID)
                            本文介绍了Joomla 获取页面 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
                        
                        问题描述
我正在尝试从 Joomla 2.5.14 获取当前的 page_id、user_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() . "
";
?>
JFactory 工作正常(我获取当前用户和日期)但 jinput 出现错误:
JFactory is working ok (I get the current user and date) but jinput is giving the error:
Notice: Undefined variable: jinput in`
推荐答案
你忘记定义$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() . "
";
?>
附带说明,您不需要使用 &.
On a side note, you don't need to use &.
希望能帮到你
这篇关于Joomla 获取页面 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
				 沃梦达教程
				
			本文标题为:Joomla 获取页面 ID
				
        
 
            
        基础教程推荐
             猜你喜欢
        
	     - 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
 - Yii2 - 在运行时设置邮件传输参数 2022-01-01
 - Web 服务器如何处理请求? 2021-01-01
 - php中的foreach复选框POST 2021-01-01
 - 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
 - php 7.4 在写入变量中的 Twig 问题 2022-01-01
 - 将变量从树枝传递给 js 2022-01-01
 - php中的PDF导出 2022-01-01
 - 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
 - PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
				
				
				
				