【问题标题】:How To Get Current Page Parameters And Properties of Joomla 3.1Joomla 3.1如何获取当前页面参数和属性
【发布时间】:2013-07-21 05:33:38
【问题描述】:

我想为我自己的网站创建一个 joomla 3.1 模块。我需要知道如何获取当前类别 id、父类别 id、当前页面 id。请有人告诉我该怎么做。感谢您的提前

【问题讨论】:

    标签: joomla


    【解决方案1】:

    从这里开始,请容忍一些不准确的地方,但它应该足以让你继续前进。

    $input = JFactory::getApplication()->input;
    
    // should be article, categories, featured, blog...
    $view = $input->get('view'); 
    
    // if it's a category view, this will be the category id, else the article id
    $id = $input->getInt('id'); 
    
    // in an article view, this will be the cat id.
    $catid = $input->getInt('catid'); 
    
    // this is the menu item id i.e. what you call page id I guess.
    $Itemid = $input->getInt('Itemid'); 
    

    【讨论】:

    • 这是工作谢谢.. 顺便说一句.. 我怎么知道什么时候可以在 $input 变量上使用“输入”语句或使用另一个语句,就像你所做的那样。谢谢
    • 通常你可以使用 $input 变量,如果你像我在代码的第 1 行那样定义它。否则它将被取消分配。我建议您阅读有关变量范围的更多信息:php.net/manual/en/language.variables.scope.php
    • 谢谢老兄!真的很有帮助
    猜你喜欢
    • 1970-01-01
    • 2022-01-28
    • 1970-01-01
    • 1970-01-01
    • 2010-10-07
    • 2011-05-07
    • 2021-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多