简体   繁体   English

如何在Joomla中将搜索模块添加为菜单项?

[英]How to add a search module as a menu item in Joomla?

My simple setup: 我的简单设置:

<div id="menuwrap"> 
    <div id="menu">
        <jdoc:include type="modules" name="menu" styles="" />
    </div>
</div>

And

ul.menu {
    display: inline-block;
}

because i need it to be centered. 因为我需要将它居中。

This is displayed as follows (imagine it is centered on the screen): 如下所示(假设它在屏幕上居中):

    Menu_Item_1 | Menu_Item_1 | Menu_Item_3

I would like to add a search box (a standard Joomla search module) as a menu item. 我想添加一个搜索框(标准的Joomla搜索模块)作为菜单项。 That is: 那是:

    Menu_Item_1 | Menu_Item_1 | Menu_Item_3 | Search...

I've tried to put the search module into another div , inside #menuwrap and float #menu to the left and #search to the right. 我试图把搜索模块到另一个div ,里面#menuwrap和浮动#menu的左侧和#search到右边。

    Menu_Item_1 | Menu_Item_1 | Menu_Item_3 |                         Search...

This is OK until resizing: 在调整大小之前可以这样做:

    Menu_Item_1 | Menu_Item_1 |
    Menu_Item_3 |
                                Search...

The #search just gets pushed under the #menu (on the third line - this is because the display of the ul is inline-block ). #search只是获取的下被推#menu (在第三行-这是因为的显示ulinline-block )。 The goal is to remain on the same line as the menu (ie, second line), as follows: 目标是与菜单保持在同一行(即第二行),如下所示:

Menu_Item_1 | Menu_Item_1 |
Menu_Item_3 | Search...

Any suggestions? 有什么建议么? Thanks. 谢谢。

If I'm understanding you correctly - you want to embed the search module itself within a menu - rather than linking to it from a menu item. 如果我对您的理解正确-您想将搜索模块本身嵌入菜单中-而不是从菜单项链接到该模块。

I think there are a number of ways to do this: 我认为有很多方法可以做到这一点:

The easiest way is to fake it. 最简单的方法是伪造它。 Put a background on the div that contains your module position - publish two modules to that position (the menu and the search module) use css to make sure they float alongside each other. 在包含模块位置的div上放置一个背景-将两个模块发布到该位置(菜单和搜索模块),然后使用css确保它们相互浮动。

Alternatively if you really need to embed the form within the same module I'd suggest creating a 'custom module chrome' to add the html of the search form to the output of any module you publish within a position that uses your custom module chrome style 另外,如果您确实需要将表单嵌入同一个模块中,建议您创建一个“自定义模块镶边”,将搜索表单的html添加到使用自定义模块镶边样式发布的任何模块的输出中

Here is an article covering the basics - probably for an older version of Joomla - but as far as I can tell the principle holds: http://docs.joomla.org/Applying_custom_module_chrome 这是一篇涵盖基础知识的文章-可能是针对Joomla的较旧版本-但据我所知,原理仍然存在: http : //docs.joomla.org/Applying_custom_module_chrome

If your goal is to add the search module as a menu item, then you need to make of it a component using this extension: 如果您的目标是将搜索模块添加为菜单项,则需要使用此扩展名使其成为组件:

http://extensions.joomla.org/extensions/core-enhancements/embed-a-include/3810 http://extensions.joomla.org/extensions/core-enhancements/embed-a-include/3810

You just need to place the module in a custom (probably hidden or nonexistent in a template) position and then you create a menuitem that points to the m2c component and use that position there. 您只需要将模块放置在自定义位置(模板中可能隐藏或不存在),然后创建一个指向m2c组件的菜单项并在其中使用该位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM