-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dfd942e
Showing
9 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Webidea24\CategorySeoText\Block; | ||
|
||
use Magento\Catalog\Model\Category; | ||
use Magento\Catalog\Model\Layer\Resolver; | ||
use Magento\Framework\View\Element\Template; | ||
|
||
class CategorySeoText extends Template | ||
{ | ||
|
||
/** | ||
* @var Resolver | ||
*/ | ||
private $catalogResolver; | ||
|
||
public function __construct( | ||
Template\Context $context, | ||
Resolver $resolver, | ||
array $data = [] | ||
) | ||
{ | ||
parent::__construct($context, $data); | ||
$this->catalogResolver = $resolver; | ||
} | ||
|
||
public function toHtml() | ||
{ | ||
if (!empty($this->getSeoText())) { | ||
return parent::toHtml(); | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
public function getSeoText() | ||
{ | ||
return $this->getCurrentCategory()->getData('wi24_seo_text'); | ||
} | ||
|
||
public function getCurrentCategory(): Category | ||
{ | ||
return $this->catalogResolver->get()->getCurrentCategory(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Webidea24\CategorySeoText\Setup; | ||
|
||
use Magento\Catalog\Model\Category; | ||
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface; | ||
use Magento\Framework\Setup\ModuleContextInterface; | ||
use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
use Magento\Framework\Setup\InstallDataInterface; | ||
use Magento\Eav\Setup\EavSetup; | ||
use Magento\Eav\Setup\EavSetupFactory; | ||
|
||
class InstallData implements InstallDataInterface | ||
{ | ||
/** | ||
* @var EavSetupFactory | ||
*/ | ||
private $eavSetupFactory; | ||
|
||
public function __construct(EavSetupFactory $eavSetupFactory) | ||
{ | ||
$this->eavSetupFactory = $eavSetupFactory; | ||
} | ||
|
||
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) | ||
{ | ||
/** @var EavSetup $eavSetup */ | ||
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); | ||
$eavSetup->addAttribute(Category::ENTITY, 'wi24_seo_text', [ | ||
'type' => 'text', | ||
'label' => 'SEO-Text', | ||
'input' => 'textarea', | ||
'visible' => true, | ||
'default' => '', | ||
'required' => false, | ||
'global' => ScopedAttributeInterface::SCOPE_STORE, | ||
'group' => 'Content', | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "webidea24/magento2-module-category-seo-text", | ||
"description": "Magento 2 Module: Add easily a seo-text to the category page on footer", | ||
"type": "magento2-module", | ||
"require": { | ||
"magento/framework": "*" | ||
}, | ||
"license": [ | ||
"MIT" | ||
], | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"Webidea24\\CategorySeoText\\": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Webidea24_CategorySeoText" setup_version="1.0.0"/> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Webidea24_CategorySeoText', __DIR__); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0"?> | ||
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> | ||
<fieldset name="content"> | ||
<field name="wi24_seo_text" template="ui/form/field" sortOrder="55" formElement="wysiwyg"> | ||
<argument name="data" xsi:type="array"> | ||
<item name="config" xsi:type="array"> | ||
<item name="wysiwygConfigData" xsi:type="array"> | ||
<item name="height" xsi:type="string">100px</item> | ||
<item name="add_variables" xsi:type="boolean">false</item> | ||
<item name="add_widgets" xsi:type="boolean">false</item> | ||
<item name="add_images" xsi:type="boolean">true</item> | ||
<item name="add_directives" xsi:type="boolean">true</item> | ||
</item> | ||
<item name="source" xsi:type="string">category</item> | ||
</item> | ||
</argument> | ||
<settings> | ||
<label translate="true">SEO-Text</label> | ||
<notice translate="true">Note: Keyboard shortcut to activate editor help : Alt + 0 (Windows) or ⌥0 (MacOS)</notice> | ||
<dataScope>wi24_seo_text</dataScope> | ||
</settings> | ||
<formElements> | ||
<wysiwyg class="Magento\Catalog\Ui\Component\Category\Form\Element\Wysiwyg"> | ||
<settings> | ||
<rows>8</rows> | ||
<wysiwyg>true</wysiwyg> | ||
</settings> | ||
</wysiwyg> | ||
</formElements> | ||
</field> | ||
</fieldset> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0"?> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<body> | ||
<referenceContainer name="content"> | ||
<block class="Webidea24\CategorySeoText\Block\CategorySeoText" name="category.seo-text" after="category.products" template="Webidea24_CategorySeoText::seo-text.phtml"/> | ||
</referenceContainer> | ||
</body> | ||
</page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
/** @var \Webidea24\CategorySeoText\Block\CategorySeoText $block */ | ||
?> | ||
<div class="category-seo-text"> | ||
<?= /** @noEscape */$block->getSeoText(); ?> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
& when (@media-common = true) { | ||
.category-seo-text { | ||
margin-top: @indent__base; | ||
} | ||
} |