根据 Magento 配置删除搜索框

Remove search box based on Magento configuration

我们如何将搜索框在所有 magento 页面上的显示与 "Mage_CatalogSearch" 的配置设置联系起来?

详细说明一下这个问题: Magento 提供在系统 -> 配置 -> 高级下禁用单个模块的输出。

在这里我们可以将 "Mage_CatalogSearch" 设置为停用。

搜索结果实际上不再显示,但是(至少在我们当前使用的模板中)搜索框仍然可见.

我更喜欢一种解决方案,它允许我们通过将 "Mage_CatalogSearch" 设置为再次启用来重新启用搜索,这应该会触发搜索框以及搜索结果再次显示,而无需修改再次编码。

非常感谢您!

亲切的问候 F

也许您可以尝试在 .phtml 中使用内置的核心辅助函数

if(Mage::helper('core')->isModuleEnabled('MyCompany_MyModule') && Mage::helper('core')->isModuleOutputEnabled('MyCompany_MyModule'))
{ /* display searchbox */ }

$isActive = Mage::getConfig()->getNode('modules/MyCompany_MyModule/active');
if ($isActive && in_array((string)$isActive, array('true', '1')))
{ /* display searchbox */ }

Mage::getConfig()->getModuleConfig('MyCompany_MyModule')->is('active', 'true'); /* which retuns true/false */

感谢@GunJan Metha 为我指明了正确的方向!

要修改的文件是(来自 magento 基础文件夹): ./app/design/frontend/[theme_package]/[主题]/template/catalogsearch/form.mini.phtml

以下代码是围绕原始 HTML 部分添加的,效果非常好:

   if(Mage::helper('core')->isModuleEnabled('Mage_CatalogSearch') && Mage::helper('core')->isModuleOutputEnabled('Mage_CatalogSearch')) {
?>
   <!-- here goes the original HTML that renders the search box -->
<?php
   }
?>