Skip to content

Commit 19668f6

Browse files
committed
Fix #13
1 parent 91bd44f commit 19668f6

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/**
4+
* @Author: Alex Dong
5+
* @Date: 2023-09-27 14:42:40
6+
* @Last Modified by: Alex Dong
7+
* @Last Modified time: 2023-09-27 14:42:56
8+
*/
9+
10+
namespace Magepow\Categories\Block\System\Config\Form\Field;
11+
12+
class Snippet extends \Magento\Config\Block\System\Config\Form\Field\Heading
13+
{
14+
15+
/**
16+
* Render element html
17+
*
18+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
19+
* @return string
20+
*/
21+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
22+
{
23+
return $this->_getElementHtml($element);
24+
}
25+
26+
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
27+
{
28+
// $html = $element->getElementHtml();
29+
$html = '';
30+
$value = $element->getData('value');
31+
$shortcodeWidget = '{{Block class="Magepow\Categories\Block\Widget\Categories" title="Magepow Categories Widget" subtitle="Magepow Categories Widget" template="categories_widget.phtml" sort_attribute="name" description="1" thumbnail="1" item_amount="1" categories="25,11,22,33" slide="1" vertical="false" infinite="true" autoplay="true" arrows="true" dots="false" speed="300" autoplaySpeed="3000" padding="15" rows="1" mobile="1" portrait="1" landscape="2" tablet="3" notebook="3" laptop="4" desktop="4" widescreen="4" visible="5"}}';
32+
33+
$html = '<ul class="categories-snippet" style="list-style: none;"><li>';
34+
$html .= '<p>' . __('Add Widget name "Magiccart Magicslider widget" and set categorie for it.') . '</p>';
35+
$html .= '<p>' . __('Example: categories="1,5,10,12"') . '</p>';
36+
$html .= '</li><li>';
37+
$html .= '<span>' . __('Copy Short code add to CMS Page/Static Block.') . '</span>';
38+
$html .= '<code style="display: block;background: #f5f5f5;padding: 15px; margin-top:15px">' . $shortcodeWidget . '</code>';
39+
$html .= '</li></ul>';
40+
41+
return $html;
42+
}
43+
}

etc/adminhtml/system.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
33
<system>
4-
<tab id="magepow" translate="label" sortOrder="102">
4+
<tab id="magepow" translate="label" sortOrder="1">
55
<label>Magepow</label>
66
</tab>
77
<section id="magepow_categories" translate="label" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
@@ -97,6 +97,14 @@
9797
<!-- <validate>validate-select</validate> -->
9898
</field>
9999
</group>
100+
<group id="shortcode" translate="label" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
101+
<label>Short code</label>
102+
<field id="snippet" translate="label comment" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
103+
<label>Snippet</label>
104+
<comment>Copy to code to page or block you want display categories</comment>
105+
<frontend_model>Magepow\Categories\Block\System\Config\Form\Field\Snippet</frontend_model>
106+
</field>
107+
</group>
100108
</section>
101109
</system>
102-
</config>
110+
</config>

0 commit comments

Comments
 (0)