Post by mike_jandreau » Sat Jul 31, 2010 2:57 am

In the default theme, I see <a onclick="moduleSearch();", but when I try to use this in my own theme, it doesn't work.

Firebug reports back: moduleSearch is not defined!

What am I missing? How can I include a search box in my theme? Is there a way I can pass keywords to the search page?

I tried:

Code: Select all

index.php?route=product/search/&keyword=<?php echo $keyword; ?>
and that doesn't work.

I tried copying the code exactly from the default theme, and that doesn't work either.

Suggestions?

New member

Posts

Joined
Mon Jul 26, 2010 1:38 am

Post by Xsecrets » Sat Jul 31, 2010 5:27 am

well your manual link doesn't work because you have an extra / should be

Code: Select all

index.php?route=product/search&keyword=<?php echo $keyword; ?>
as for what you are missing. it will be the javascript function. I'm not sure what file it's in it's either in the header.tpl or in one of the file in the javascript folder. If you put that script into your header or include the file your search should start working.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by mike_jandreau » Sat Jul 31, 2010 8:34 am

I tried that, and it didn't work.

Echo keyword won't likely work, because that's what I'm trying to set as my action on the search form. ie;

Code: Select all

<form action="index.php?route=product/search&keyword=XX
What I can't figure out is how to popular that url with what the person types into the box.

I'm used to WordPress, where you just give the value of %s for the variable they type in, but that doesn't work here.

I'll play around with it some more, but if anyone has any other suggestions as to how to incorporate a search into the header of a custom theme, I'd love to hear it.

New member

Posts

Joined
Mon Jul 26, 2010 1:38 am

Post by Xsecrets » Sat Jul 31, 2010 8:49 am

form actions should be

Code: Select all

<form action="index.php?route=product/search">
and the input should be

Code: Select all

<input type="text" name="keyword"

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by mike_jandreau » Sat Jul 31, 2010 10:19 am

Xsecrets wrote:form actions should be

Code: Select all

<form action="index.php?route=product/search">
Just about got it! However, this code doesn't work:

Code: Select all

          <form action="index.php?route=product/search">
          <input type="text" name="keyword" class="searchfeild"/>
          </form>
The question mark and anything after it are ignored, so the page loads as index.php?keyword=, which obviously fails.

Any idea why the question mark and stuff after it are ignored by the form? Even when I add a method of GET or POST it doesn't work. POST sends to the right URL, but doesn't pass &keyword=, GET works the same way as above.

New member

Posts

Joined
Mon Jul 26, 2010 1:38 am

Post by Xsecrets » Sat Jul 31, 2010 10:39 am

mike_jandreau wrote:
Xsecrets wrote:form actions should be

Code: Select all

<form action="index.php?route=product/search">
Just about got it! However, this code doesn't work:

Code: Select all

          <form action="index.php?route=product/search">
          <input type="text" name="keyword" class="searchfeild"/>
          </form>
The question mark and anything after it are ignored, so the page loads as index.php?keyword=, which obviously fails.

Any idea why the question mark and stuff after it are ignored by the form? Even when I add a method of GET or POST it doesn't work. POST sends to the right URL, but doesn't pass &keyword=, GET works the same way as above.
hmm not really sure why it won't take it, but just to make it easy try this

Code: Select all

<form action="index.php" method="get">
<input type="hidden" name="route" value="product/search" />
<input type="text" name="keyword" class="blah" />
</form>

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by mike_jandreau » Sat Jul 31, 2010 10:44 am

Excellent, that worked.

It encodes the / in product/search as %2F, but that doesn't matter, because it works.

Thanks again!

New member

Posts

Joined
Mon Jul 26, 2010 1:38 am

Post by bedo02 » Sun Aug 08, 2010 5:10 pm

Hi,
here is my search script which I am using in header as well :

Code: Select all

        <div id="drvt_head_search">
        <div id="drvt_search">
          <div class="drvt_search_div8"><?php echo $entry_search; ?>&nbsp;</div>
          <div class="drvt_search_div9">
            <?php if ($keyword) { ?>
            <input type="text" value="<?php echo $keyword; ?>" id="filter_keyword" />
            <?php } else { ?>
            <input type="text" value="<?php echo $text_keyword; ?>" id="filter_keyword" onclick="this.value = '';"  />
            <?php } ?>
            <select id="filter_category_id">
              <option value="0"><?php echo $text_category; ?></option>
              <?php foreach ($categories as $category) { ?>
              <?php if ($category['category_id'] == $category_id) { ?>
              <option value="<?php echo $category['category_id']; ?>" selected="selected"><?php echo $category['name']; ?></option>
              <?php } else { ?>
              <option value="<?php echo $category['category_id']; ?>"><?php echo $category['name']; ?></option>
              <?php } ?>
              <?php } ?>
            </select>
          </div>
          <div class="drvt_search_div10">&nbsp;&nbsp;<a onclick="moduleSearch();" class="drvt_button"><span><?php echo $button_go; ?></span></a> </div>
        </div>  
        </div>
I hope this will help to somebody else as well. See it working at http://drevotoys.eu
OC 1.4.7

using oc 1.5.6


Newbie

Posts

Joined
Mon Oct 26, 2009 9:43 pm
Who is online

Users browsing this forum: No registered users and 9 guests