简体   繁体   中英

php or javascript search in joomla

I am hoping you guys can help me out I am sure its simple.

I want to make a joomla module or use one of the custom modules that allow me to add Javascript or Php(Not sure which I need to use for this).

What I want to do is have a text box and when that person types in something in that textbox it goes to that page.

For example: I type in the text box: House for rent

And then the page that will open is: www.mywebsite.com/somesearch/house for rent

How would I go about achieving this?

Question is very vague. So instead of providing all the code to make your own, I would recommend using an extension such as RokAjaxSearch which is a powerful search module that uses Ajax to prevent page refreshing. It also has the option to include Google results.

Update

You can also use the default Joomla search modules. In the Joomla backend, under Components (top menu) go to Smart Search , then click Search Filter on the ton tab. Add a new filter and set to Search All . Once done, go to the Module Manager and open the Smart Search module. Set a position for the module and select the filter you created before.

Hope this helps

The question is not very clear but assuming the page www.mywebsite.com/somesearch/searchtext is resolving to a page that can access the query string in the URL and process the search with the searchtext you can do something like this:

<html>
<head>
<script>
$('#searchButton').click(function(){
   var searchText = document.getElementById('searchBox').value;
   window.location.href = 'http://www.mywebsite/somesearch/'+encodeURIComponent(searchText);
})
</script>
</head>
<body>
<input type='text' id='searchBox' />
<input type='submit' id='searchButton' value='Search' />
</body>
</html>

You can use one of the available modules that let you write JavaScript, HTML or PHP code as a module listed here: http://extensions.joomla.org/extensions/edition/custom-code-in-modules

If you do this you can skip the html, head and body tags. Just put the <script>...</script> and then the input .

Also be careful processing the user input directly without escaping it against possible sql injection attacks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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