生成元页面标题与页面的h1标题标签完全相同

Ruc*_*ika 16 html php joomla

网站基于Joomla

我有很多页面,其中h1 - header被提及为产品细节,并根据产品详细信息通过php显示

有2个文件

<h1>Used <?php echo $this->CatName; ?> <?php echo $this->prodDet->prod_name;?> Toy for Sale </h1>
Run Code Online (Sandbox Code Playgroud)

cdefault.php`有这个代码

$this->document->setTitle($title);
Run Code Online (Sandbox Code Playgroud)

这会正确显示h1标签.

现在我想生成页面的元标题并使用此文件中生成的h1输出 h1

我相信这一行是定义页面标题的

"{$this->item->heading}";
Run Code Online (Sandbox Code Playgroud)

这一行定义了标题h1

protected function _prepareDocument()
{
  $app = JFactory::getApplication();
  $menus = $app->getMenu();
  $title = null;

  // Because the application sets a default page title,
  // We need to get it from the menu item itself
  $menu = $menus->getActive();

  if ($menu)
  {
    $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
  }
  else
  {
    $this->params->def('page_heading', JText::_('COM_USEDCAR_DEFAULT_PAGE_TITLE'));
  }

  $title = $this->params->get('page_title', '');

  if (empty($title))
  {
    $title = $app->get('sitename');
  }
  elseif ($app->get('sitename_pagetitles', 0) == 1)
  {
    $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
  }
    elseif ($app->get('sitename_pagetitles', 0) == 2)
  {
    $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
  }

  $title = "{$this->item->heading}";
  $this->document->setTitle($title);

  if ($this->params->get('menu-meta_description'))
  {
    $this->document->setDescription($this->params->get('menu-meta_description'));
  }

  if ($this->params->get('menu-meta_keywords'))
  {
    $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
  }

  if ($this->params->get('robots'))
  {
     $this->document->setMetadata('robots', $this->params->get('robots'));
  }
}
Run Code Online (Sandbox Code Playgroud)

从页面标题中提取h1

这是完整的代码

<h1>Used <?php echo $this->CatName; ?> <?php echo $this->prodDet->prod_name;?> Toy for Sale </h1>
Run Code Online (Sandbox Code Playgroud)

标题标签中的输出是default.php.可以任何人帮助并建议如何把这个h1标签输出而不是view.html.php

小智 0

为什么不将h1内容作为参数发送到 php-document ,然后使用标签内的GET内容输出它?除非您避免动态回显,否则这可能是将文本输出为.echotitletitle