如何通过joomla中的ID获取文章的完整网址? [英] How to get full url of a article by it's ID in joomla?

查看:75
本文介绍了如何通过joomla中的ID获取文章的完整网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有文章ID,如何获得本文的有效完整网址?本文已与菜单相关,但我可能不知道,php中是否有任何简单的方法来获取 url ?我正在使用joomla 3.2 我已经尝试过关注.

I have article id, How can I get valid full url of this article? This article already associated with menu but I might not know, is there any easy way in php to get url? I am using joomla 3.2 I tried following already.

$article = ControllerLegacy::getInstance('Content')->getModel('Article')->getItem($article‌​Id); 
JRoute::_(ContentHelperRoute::getArticleRoute($articleId,$article->catid))

推荐答案

您可以这样使用

 $article = JControllerLegacy::getInstance('Content')
            ->getModel('Article')->getItem($articleId);

  $url =  JRoute::_(ContentHelperRoute::getArticleRoute($articleId, 
                      $article->catid, 
                      $article->language))

这篇关于如何通过joomla中的ID获取文章的完整网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆