jonsecu Posted April 27, 2014 Share Posted April 27, 2014 Hi... I have generated a custom front module controller with its php and tpl files. I can access it through an URL with this form: http://domain.com/tkn/index.php?fc=module&module=modulename&controller=default&id_example=1 Currently this php controller retrieves from the database some info based on the last id_example value and displays information by generating smarty variables and passing them to the default.tpl view. I would like to generate as well some metatags on the header like this: <meta property="og:title" content="Content Example" /> <meta property="og:type" content="article" /> <meta property="og:url" content="http://domain.com/tkn/index.php?fc=module&module=modulename&controller=default&id_example=1" /> <meta property="og:image" content="http://domain.com/image.jpg" /> <meta property="og:description" content="Description Here" /> <meta property="og:site_name" content="Site Name" /> I want to do this so that when someone shares this front view controller, Facebook pulls automatically the information I placed on the tags here. I want to pass the tags contents through smarty variables. How should I get this done so that this meta tags appear only on the front controller view of this particular module? Currently I used a hook on the modules main php to the header like this: public function hookDisplayHeader($params) { $this->context->controller->addCSS($this->_path.'filename.css', 'all'); $this->context->controller->addJS($this->_path.'filename.js', 'all'); return $this->display(__FILE__, 'module-header.tpl'); } And wrote the meta tags on module-header.tpl... however, since it is a hook to the global header, the meta tags affect every page on the whole site. How can I write meta tags just to the module header? Thank you very much! Link to comment Share on other sites More sharing options...
misthero Posted May 19, 2014 Share Posted May 19, 2014 (edited) public function hookDisplayHeader($params) { if (Tools::getValue('module') == $this->name){ $this->context->controller->addCSS($this->_path.'filename.css', 'all'); $this->context->controller->addJS($this->_path.'filename.js', 'all'); return $this->display(__FILE__, 'module-header.tpl'); } return; } Edited May 19, 2014 by misthero (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now