Skip to content

Commit 497540f

Browse files
committed
Use HTML Comments Based on Admin Config
1 parent 0f10db5 commit 497540f

4 files changed

Lines changed: 33 additions & 1 deletion

File tree

Plugin/AddCmsBlockIdentifierToMarkup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function beforeSave(
5454
0
5555
)
5656
);
57-
} else {
57+
} else if ($this->moduleConfig->useHtmlComments()) {
5858
$block->setContent('<!-- CMS identifier = ' . $identifier . ' -->' . "\n" . $content);
5959
}
6060
}

Scope/Config.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Config
1414
{
1515
const XML_PATH_CMS_IDENTIFIER_MARKUP_ENABLED = 'cms/pagebuilder/block_identifier_markup_enabled';
1616
const XML_PATH_CMS_IDENTIFIER_DATA_ATTR_NAME = 'cms/pagebuilder/block_identifier_attribute_name';
17+
const XML_PATH_CMS_IDENTIFIER_HTML_COMMENT = 'cms/pagebuilder/block_identifier_comment';
1718

1819
/** @var ScopeConfigInterface */
1920
private ScopeConfigInterface $scopeConfig;
@@ -52,4 +53,17 @@ public function getBlockIdentifierDataAttributeName($scopeCode = null): string
5253
$scopeCode
5354
);
5455
}
56+
57+
/**
58+
* @param int|string|null $scopeCode
59+
* @return bool
60+
*/
61+
public function useHtmlComments($scopeCode = null): bool
62+
{
63+
return $this->scopeConfig->isSetFlag(
64+
self::XML_PATH_CMS_IDENTIFIER_HTML_COMMENT,
65+
ScopeInterface::SCOPE_STORE,
66+
$scopeCode
67+
);
68+
}
5569
}

etc/adminhtml/system.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@
4141
<field id="cms/pagebuilder/block_identifier_markup_enabled">1</field>
4242
</depends>
4343
</field>
44+
<field id="block_identifier_comment"
45+
translate="label comment"
46+
type="select"
47+
sortOrder="3020"
48+
showInDefault="1"
49+
showInWebsite="1"
50+
showInStore="1"
51+
canRestore="1">
52+
<label>Use HTML Comments for non-HTML Content</label>
53+
<comment>
54+
A HTML comment will be used when the block content does not contain a wrapping HTML tag to edit.
55+
</comment>
56+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
57+
<depends>
58+
<field id="cms/pagebuilder/block_identifier_markup_enabled">1</field>
59+
</depends>
60+
</field>
4461
</group>
4562
</section>
4663
</system>

etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<pagebuilder>
1313
<block_identifier_markup_enabled>1</block_identifier_markup_enabled>
1414
<block_identifier_attribute_name>block-identifier</block_identifier_attribute_name>
15+
<block_identifier_comment>1</block_identifier_comment>
1516
</pagebuilder>
1617
</cms>
1718
</default>

0 commit comments

Comments
 (0)