我尝试通过ID
访问文章(假设ID为179),但是在我的Joomla 3.9.3网站中,该页面显示为空白页面,没有任何反应。
这是我的代码(名称get.php
,它与configuration.php
,index.php
,robots.txt
...位于同一根文件夹中)
<?php
error_reporting(E_ALL);
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
define('_JEXEC', 1);
define('JPATH_BASE', realpath(dirname(__FILE__)));
require_once ( JPATH_BASE .'/includes/defines.php' );
require_once ( JPATH_BASE .'/includes/framework.php' );
require_once ( JPATH_BASE .'/libraries/joomla/factory.php' );
$app = JFactory::getApplication('');
var_dump($app);
$app->initialise();
$db = JFactory::getDBO();// Joomla database object
$sql = "SELECT fulltext FROM #_content WHERE id = 179";
$db->setQuery($sql);
$fullArticle = $db->loadResult();
if(!strlen(trim($fullArticle))) $fullArticle = "Article is empty ";
echo $fullArticle;
?>
我var_dump()
时什么也没显示;
我做错了什么,还是Joomla 3.9.3改变了我们的访问方式?
答案 0 :(得分:1)
您可以尝试以下代码-
<?php
error_reporting(E_ALL);
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
define('_JEXEC', 1);
define('JPATH_BASE', realpath(dirname(__FILE__)));
require_once ( JPATH_BASE .'/includes/defines.php' );
require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';
$app = JFactory::getApplication('site');
// var_dump($app);
// $app->initialise();
$db = JFactory::getDBO();// Joomla database object
$sql = "SELECT `fulltext` FROM #__content WHERE id = 179";
$db->setQuery($sql);
$fullArticle = $db->loadResult();
if(!strlen(trim($fullArticle))) $fullArticle = "Article is empty ";
echo $fullArticle;