【问题标题】:how to use my description(meta description) as a second title in joomla2.5如何在 joomla 2.5 中使用我的描述(元描述)作为第二个标题
【发布时间】:2014-04-27 15:26:46
【问题描述】:

我想在 joomla 2.5.x 中使用文章描述部分(元描述)作为第二个标题。

并将其放在标题旁边的文章中。

为此,我使用以下命令。

<?php 

jimport( 'joomla.document.document' );

function getDescription() {
    return $this->description;
}

echo "<h3>".getDescription()."</h3>";

?>

我把它放在下面的文件中,但是没有用。

components\com_content\views\article\tmpl\default.php

【问题讨论】:

  • 我还没有测试过,但你可能只能echo $this-&gt;item-&gt;metadesc;
  • 谢谢。我找到了另一种方式。$doc =JFactory::getDocument(); $meta_description = $doc->getMetaData("description"); echo "

    ".$meta_description."

    ";

标签: php joomla


【解决方案1】:

我将@hhgh4269 提供的答案从 cmets 中提取出来并放入答案中,以帮助未来的访问者解决这个问题。

这与最初提出的问题略有不同。相反,它是使用这个来完成的:

$doc =JFactory::getDocument(); 
$meta_description = $doc->getMetaData("description"); 
echo "<h3>".$meta_description."</h3>";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-18
    • 1970-01-01
    • 2011-09-06
    • 2011-09-01
    • 2011-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多