Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make title different from meta title on CMS for SEO purpose #9475

Merged
merged 2 commits into from Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions classes/CMS.php
Expand Up @@ -32,6 +32,7 @@ class CMSCore extends ObjectModel
/** @var string Name */
public $id;
public $id_cms;
public $head_seo_title;
public $meta_title;
public $meta_description;
public $meta_keywords;
Expand Down Expand Up @@ -60,6 +61,7 @@ class CMSCore extends ObjectModel
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
'head_seo_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
'content' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 3999999999999),
),
Expand Down
1 change: 1 addition & 0 deletions classes/Meta.php
Expand Up @@ -482,6 +482,7 @@ public static function getCmsMetas($idCms, $idLang, $pageName)
$cms = new CMS($idCms, $idLang);
if (Validate::isLoadedObject($cms)) {
$row = Meta::getPresentedObject($cms);
$row['meta_title'] = !empty($row['head_seo_title']) ? $row['head_seo_title'] : $row['meta_title'];

return Meta::completeMetaTags($row, $row['meta_title']);
}
Expand Down
18 changes: 16 additions & 2 deletions controllers/admin/AdminCmsController.php
Expand Up @@ -59,6 +59,7 @@ public function __construct()
'id_cms' => array('title' => $this->trans('ID', array(), 'Admin.Global'), 'align' => 'center', 'class' => 'fixed-width-xs'),
'link_rewrite' => array('title' => $this->trans('URL', array(), 'Admin.Global')),
'meta_title' => array('title' => $this->trans('Title', array(), 'Admin.Global'), 'filter_key' => 'b!meta_title'),
'head_seo_title' => array('title' => $this->trans('Meta title', array(), 'Admin.Global'), 'filter_key' => 'b!head_seo_title'),
'position' => array('title' => $this->trans('Position', array(), 'Admin.Global'), 'filter_key' => 'position', 'align' => 'center', 'class' => 'fixed-width-sm', 'position' => 'position'),
'active' => array('title' => $this->trans('Displayed', array(), 'Admin.Global'), 'align' => 'center', 'active' => 'status', 'class' => 'fixed-width-sm', 'type' => 'bool', 'orderby' => false),
);
Expand Down Expand Up @@ -135,13 +136,26 @@ public function renderForm()
),
array(
'type' => 'text',
'label' => $this->trans('Meta title', array(), 'Admin.Global'),
'label' => $this->trans('Title', array(), 'Admin.Global'),
'name' => 'meta_title',
'id' => 'name', // for copyMeta2friendlyURL compatibility
'lang' => true,
'required' => true,
'class' => 'copyMeta2friendlyURL',
'hint' => $this->trans('Invalid characters:', array(), 'Admin.Notifications.Info') . ' <>;=#{}',
'hint' => array(
$this->trans('Used in the h1 page tag, and as the default title tag value.', array(), 'Admin.Design.Help'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this wording be a tooltip?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect domains then, thanks @mreker!

$this->trans('Invalid characters:', array(), 'Admin.Notifications.Info') . ' <>;=#{}',
),
),
array(
'type' => 'text',
'label' => $this->trans('Meta title', array(), 'Admin.Global'),
'name' => 'head_seo_title',
'lang' => true,
'hint' => array(
$this->trans('Used to override the title tag value. If left blank, the default title value is used.', array(), 'Admin.Design.Help'),
$this->trans('Invalid characters:', array(), 'Admin.Notifications.Info') . ' <>;=#{}',
),
),
array(
'type' => 'text',
Expand Down
1 change: 1 addition & 0 deletions install-dev/data/db_structure.sql
Expand Up @@ -376,6 +376,7 @@ CREATE TABLE `PREFIX_cms_lang` (
`id_lang` int(10) unsigned NOT NULL,
`id_shop` int(10) unsigned NOT NULL DEFAULT '1',
`meta_title` varchar(128) NOT NULL,
`head_seo_title` varchar(255) DEFAULT NULL,
`meta_description` varchar(255) DEFAULT NULL,
`meta_keywords` varchar(255) DEFAULT NULL,
`content` longtext,
Expand Down
3 changes: 3 additions & 0 deletions install-dev/upgrade/sql/1.7.5.0.sql
Expand Up @@ -4,3 +4,6 @@ SET NAMES 'utf8';
/* PHP:add_supplier_manufacturer_routes(); */;

/* PHP:ps_1750_update_module_tabs(); */;

ALTER TABLE `PREFIX_cms_lang`
ADD `head_seo_title` varchar(255) DEFAULT NULL AFTER `meta_title`;