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

#482 - added meta title field to cms pages #3636

Merged
merged 3 commits into from May 3, 2016
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
16 changes: 16 additions & 0 deletions app/code/Magento/Cms/Api/Data/PageInterface.php
Expand Up @@ -18,6 +18,7 @@ interface PageInterface
const IDENTIFIER = 'identifier';
const TITLE = 'title';
const PAGE_LAYOUT = 'page_layout';
const META_TITLE = 'meta_title';
const META_KEYWORDS = 'meta_keywords';
const META_DESCRIPTION = 'meta_description';
const CONTENT_HEADING = 'content_heading';
Expand Down Expand Up @@ -62,6 +63,13 @@ public function getTitle();
*/
public function getPageLayout();

/**
* Get meta title
*
* @return string|null
*/
public function getMetaTitle();

/**
* Get meta keywords
*
Expand Down Expand Up @@ -192,6 +200,14 @@ public function setTitle($title);
*/
public function setPageLayout($pageLayout);

/**
* Set meta title
*
* @param string $metaTitle
* @return \Magento\Cms\Api\Data\PageInterface
*/
public function setMetaTitle($metaTitle);

/**
* Set meta keywords
*
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Cms/Block/Page.php
Expand Up @@ -101,7 +101,8 @@ protected function _prepareLayout()
$page = $this->getPage();
$this->_addBreadcrumbs($page);
$this->pageConfig->addBodyClass('cms-' . $page->getIdentifier());
$this->pageConfig->getTitle()->set($page->getTitle());
$metaTitle = $page->getMetaTitle();
$this->pageConfig->getTitle()->set($metaTitle ? $metaTitle : $page->getTitle());
$this->pageConfig->setKeywords($page->getMetaKeywords());
$this->pageConfig->setDescription($page->getMetaDescription());

Expand Down
21 changes: 21 additions & 0 deletions app/code/Magento/Cms/Model/Page.php
Expand Up @@ -168,6 +168,16 @@ public function getPageLayout()
return $this->getData(self::PAGE_LAYOUT);
}

/**
* Get meta title
*
* @return string|null
*/
public function getMetaTitle()
{
return $this->getData(self::META_TITLE);
}

/**
* Get meta keywords
*
Expand Down Expand Up @@ -352,6 +362,17 @@ public function setPageLayout($pageLayout)
return $this->setData(self::PAGE_LAYOUT, $pageLayout);
}

/**
* Set meta title
*
* @param string $metaTitle
* @return \Magento\Cms\Api\Data\PageInterface
*/
public function setMetaTitle($metaTitle)
{
return $this->setData(self::META_TITLE, $metaTitle);
}

/**
* Set meta keywords
*
Expand Down
41 changes: 41 additions & 0 deletions app/code/Magento/Cms/Setup/UpgradeSchema.php
@@ -0,0 +1,41 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Cms\Setup;

use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;

/**
* Upgrade the Cms module DB scheme
*/
class UpgradeSchema implements UpgradeSchemaInterface
{
/**
* {@inheritdoc}
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$this->addMetaTitleField($setup);
}
}
protected function addMetaTitleField(SchemaSetupInterface $setup)
{
$setup->getConnection()->addColumn(
$setup->getTable('cms_page'),
'meta_title',
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 255,
'nullable' => true,
'comment' => 'Page Meta Title'
]
);
return $this;
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Cms/etc/module.xml
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_Cms" setup_version="2.0.0">
<module name="Magento_Cms" setup_version="2.0.1">
<sequence>
<module name="Magento_Store"/>
<module name="Magento_Theme"/>
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Cms/i18n/en_US.csv
Expand Up @@ -124,3 +124,4 @@ Blocks,Blocks
Widgets,Widgets
Themes,Themes
Schedule,Schedule
"Meta Title","Meta Title"
11 changes: 11 additions & 0 deletions app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_form.xml
Expand Up @@ -148,6 +148,17 @@
</item>
</argument>
</field>
<field name="meta_title">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Meta Title</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">page</item>
<item name="dataScope" xsi:type="string">meta_title</item>
</item>
</argument>
</field>
<field name="meta_keywords">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
Expand Down
Expand Up @@ -302,6 +302,16 @@
</item>
</argument>
</column>
<column name="meta_title">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Meta Title</item>
<item name="visible" xsi:type="boolean">false</item>
</item>
</argument>
</column>
<column name="meta_keywords">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
Expand Down