[英]Joomla add some meta tags one page
I have a page for job in my joomla and I want to add some tags to the header of this page, using controller but I never used joomla I don't know how 我在joomla中有一个工作页面,我想使用控制器将一些标签添加到此页面的标题中,但我从未使用过joomla,我不知道如何
the tags are: 标签是:
<meta property="og:title" content="link_title">
<meta property="og:url" content="page_url">
<meta property="og:description" content="page_description">
My controller is in 我的控制器在
/home/ly/web/site/http/components/com_mks_career/controller.php
and my view is 我的看法是
/home/ly/web/site/http/templates/kms/html/com_mks_career/job/default.php
I found this code but I don't know where to call it and how to use it 我找到了此代码,但不知道在哪里调用以及如何使用它
$this->document->setMetaData( 'og:image', JURI::base().'imagename.jpg');
$this->document->setMetaData( 'og:title' , $pagetitle );
$this->document->setMetaData( 'og:description' , $item->metadesc );
$this->document->setMetaData( 'og:url' , JURI::base().$_SERVER ['REQUEST_URI'] );
$this->document->setMetaData( 'og:site_name' , $this->conf->get('config.sitename'));
$this->document->setMetaData( 'og:type' , 'cat:type' );
Here's some untested code to get you started, you would add it to your page template, in the section where it builds up the head content of your page 这是一些未经测试的代码,可以帮助您入门,您可以将其添加到页面模板的“构建页面标题内容”部分中。
$doc = JFactory::getDocument();
// Get ID of current page
$id = JFactory::getApplication()->input->getInt('id');
// Define your custom meta tags
$link_title = "custom tag 1";
$page_url = "custom tag 2";
$page_description = "custom tag 3";
// the ID of the page I wanted to customise
if ($id == 123){
// add your tags for for page ID=123 here
$doc->setMetaData('og:title', $link_title);
$doc->setMetaData('og:url', $page_url);
$doc->setMetaData('og:description', $page_description);
}
I hope this helps! 我希望这有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.