php 如何修改 Joomla 默认搜索模块?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2116010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 05:06:06  来源:igfitidea点击:

How to modify Joomla default search module?

phpjoomlamodule

提问by ria

I want to remove the label "Search" in Joomla search module (default search module). I have modified the default_form.php from the directory /joomla15/components/com_search/views/search/tmpl/ and even removed the following code but it makes no difference on the site:

我想删除 Joomla 搜索模块(默认搜索模块)中的“搜索”标签。我已经修改了目录 /joomla15/components/com_search/views/search/tmpl/ 中的 default_form.php 甚至删除了以下代码,但它在网站上没有任何区别:

<label for="search_searchword">
    <?php echo JText::_( 'Search Keyword' ); ?>:
</label>

Actually i am using an image button for the Search and I dont want the label to be displayed. What should I do to remove it?

实际上,我正在使用图像按钮进行搜索,但我不希望显示标签。我应该怎么做才能删除它?

回答by GmonC

You shouldn't be hacking Joomla Core Files. If you want to change a view from a component, you should use Template Overrides.

你不应该破解 Joomla Core Files。如果要从组件更改视图,则应使用Template Overrides

Second, if you're modifying your search component, you have to remember that the extensions in Joomla are divided in "Components", "Plugins" and "Modules". Every module is an extension, but not every extension is a module. It's a little different from other CMS's you may be used to.

其次,如果你正在修改你的搜索组件,你必须记住 Joomla 中的扩展被分为“组件”、“插件”和“模块”。每个模块都是一个扩展,但不是每个扩展都是一个模块。它与您可能习惯的其他 CMS 略有不同。

That's why you can't change your search "module". You're searching for it's templates in components folder when you should be looking into "modules" folder as well.

这就是您无法更改搜索“模块”的原因。当您还应该查看“模块”文件夹时,您正在组件文件夹中搜索它的模板。

There's a search module, that appears in all pages. This module is in JOOMA_PATH/modules/mod_search/tmpl/default.php, and you should be copying it to JOOMA_PATH/templates/TEMPLATE_NAME/html/mod_search/default.phpto add your modifications. This is way, when updating your Joomla installation, you're not going to lose your customizations.

有一个search module, 出现在所有页面中。此模块位于 中JOOMA_PATH/modules/mod_search/tmpl/default.php,您应该将其复制到JOOMA_PATH/templates/TEMPLATE_NAME/html/mod_search/default.php以添加修改。这样,当更新您的 Joomla 安装时,您不会丢失您的自定义设置。

回答by Crozin

I never used Joomla! so I just guess but maybe there's some kind of template cache? Try to clear it.

我从来没有用过 Joomla!所以我只是猜测,但也许有某种模板缓存?尝试清除它。

But what you're trying to do is a very bad practice. This label makes your forms more available (for screen readers etc.). Don't try to remove this element - just hide it using CSS:

但是你试图做的是一种非常糟糕的做法。此标签使您的表单更可用(用于屏幕阅读器等)。不要试图删除这个元素 - 只需使用 CSS 隐藏它:

#mySearchForm label {
    display: none;
}

回答by Thilanka De Silva

Search module ---> basic options---> box label (type 1 or two space, then the "search..." will disappear)

搜索模块--->基本选项--->框标签(输入1或2个空格,那么“搜索...”就会消失)