如何在Joomla中按文章ID获取文章文字? [英] How to get article text by article ID in Joomla?

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

问题描述

我想通过传递joomla模板中的商品ID来获取商品文字.

I want to get article text by passing article ID from the joomla template.

推荐答案

简单,为您发送带有post/get的商品ID,并使用变量"id"作为编号:

Simple, providing you sending an article id with post/get and using variable "id" as its number:

$articleId = JRequest::getInt('id');
$db =& JFactory::getDBO();

$sql = "SELECT fulltext FROM #__content WHERE id = ".intval($articleId);
$db->setQuery($sql);
$fullArticle = $db->loadResult();

if(!strlen(trim($fullArticle))) $fullArticle = "Article is empty ";

从任何地方获取articleId:

to get articleId from anywhere:

$articleId = (JRequest::getVar('option')==='com_content' && JRequest::getVar('view')==='article')? JRequest::getInt('id') : 0;

这篇关于如何在Joomla中按文章ID获取文章文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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