查询数据库在GetOne上失败

时间:2012-08-22 11:34:33

标签: php mysql joomla joomla2.5

http://docs.joomla.org/Search_Engine_Optimisation

Dynamic MetaDesc in a list of articles by category

部分

我已经关注,我收到致命错误,指出Call to a member function GetOne() on a non-object in D:\xampp\htdocs\zoomla\includes\application.php on line 391

有人可以帮我解决这个问题吗?谢谢。顺便说一句,上一节不适合Joomla 2.5你能帮助我吗?

Add Heading Tags in the Titles for More Relevance怎么样????对于Joomla 2.5

2 个答案:

答案 0 :(得分:0)

对于旧版本的Joomla来说似乎是这样。

此代码段:

if (strcasecmp($_GET['view'],'category')==0) {         
   $description = $database->GetOne("SELECT description FROM #__categories WHERE id={$_GET['id']}");       
}

很可能与(在Joomla 2.5中)相同:

if (strcasecmp($_GET['view'],'category')==0) {
   $db = JFactory::getDBO();
   $db->setQuery("SELECT description FROM #__categories WHERE id=".(int)$_GET['id']);
   $description = $db->loadResult();       
}

请注意我的代码未经过测试。

答案 1 :(得分:0)

那篇文章与Joomla无关! 2.5。对于初学者,类别视图已包含元描述和关键字(如果它们存在于view.html.php

中)
if ($this->category->metadesc)
{
    $this->document->setDescription($this->category->metadesc);
}
elseif (!$this->category->metadesc && $this->params->get('menu-meta_description'))
{
    $this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->category->metakey)
{
    $this->document->setMetadata('keywords', $this->category->metakey);
}
elseif (!$this->category->metakey && $this->params->get('menu-meta_keywords'))
{
    $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}

这同样适用于向文章标题添加标题标签的部分:

<?php if ($params->get('show_title')) : ?>
    <h2>
    <?php if ($params->get('link_titles') && !empty($this->item->readmore_link)) : ?>
        <a href="<?php echo $this->item->readmore_link; ?>">
        <?php echo $this->escape($this->item->title); ?></a>
    <?php else : ?>
        <?php echo $this->escape($this->item->title); ?>
    <?php endif; ?>
    </h2>
<?php endif; ?>

如果您确实想要更改输出的方式,则应在模板中为com_content创建template overrides