Skip to content

Commit 950fb30

Browse files
author
Bohdan Berezhniy
committed
procesed comments for hyva
1 parent fd3e5e9 commit 950fb30

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

Block/Adminhtml/System/Config/Form/Info.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,42 @@ protected function getModuleTitle()
2828
{
2929
return 'Product Label Extension';
3030
}
31+
32+
/**
33+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
34+
* @return string
35+
*/
36+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
37+
{
38+
return $this->processHyva() . parent::render($element);
39+
}
40+
41+
/**
42+
* @return string
43+
*/
44+
private function processHyva()
45+
{
46+
$result = '';
47+
48+
$hyvaThemeDetector = \Magento\Framework\App\ObjectManager::getInstance()->get(
49+
\Magefan\Community\Api\HyvaThemeDetectionInterface::class
50+
);
51+
52+
if ($hyvaThemeDetector->execute(0)) {
53+
$script = 'document.body.classList.add("hyva")';
54+
$result = $this->mfSecureRenderer->renderTag('script', [], $script, false);
55+
$result .= '
56+
<style>
57+
#mfproductlabel_general .hyva {display: block; font-weight: bold;}
58+
</style>
59+
';
60+
} else {
61+
$result = '
62+
<style>
63+
#mfproductlabel_general .hyva {display: none;}
64+
</style>';
65+
}
66+
67+
return $result;
68+
}
3169
}

etc/adminhtml/system.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,18 @@
2828

2929
<field id="pp_selector" translate="css class parent label container" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
3030
<label>Product Page Label Container</label>
31-
<comment>Selector for Container [For Hyva use: "relative self-center w-full"]</comment>
31+
<comment><![CDATA[
32+
Selector for Container <span class="hyva">[For Hyva Theme use: "relative self-center w-full"]</span>
33+
]]>
34+
</comment>
3235
</field>
3336

3437
<field id="pl_selector" translate="css class parent label container" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
3538
<label>Product List Label Container</label>
36-
<comment>Only one class that located above the product image! [For Hyva use: "product-image-photo"]</comment>
39+
<comment><![CDATA[
40+
Only one class that located above the product image! <span class="hyva">[For Hyva Theme use: "product-image-photo"]</span>
41+
]]>
42+
</comment>
3743
</field>
3844
<field id="exclude_page_types" translate="label" type="multiselect" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
3945
<label>Don't Use On Pages</label>

0 commit comments

Comments
 (0)