Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Search Box in the top


shahed

Recommended Posts

I like to have a search box in header.php, I tried to modified searchbox but couldnt do it, is there a easy way? how do I modify this code to a simple search box and submit button .

 <tr>

           <td>



 $info_box_contents = array();

 $info_box_contents[] = array('align' => 'left',

                              'text'  => BOX_HEADING_SEARCH

                             );

 new infoBoxHeading($info_box_contents, false, false);



 $hide = tep_hide_session_id();

 $info_box_contents = array();

 $info_box_contents[] = array('form'  => '<form name="quick_find" method="get" action="' . tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false) . '">',

                              'align' => 'center',

                              'text'  => $hide . '<input type="text" name="keywords" size="10" maxlength="30" value="' . htmlspecialchars(StripSlashes(@$HTTP_GET_VARS["keywords"])) . '"> ' . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . '<br>' . BOX_SEARCH_TEXT . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>'

                             );

 new infoBox($info_box_contents);



           </td>

         </tr>

Link to comment
Share on other sites

It should not be hard at all.

The problem lies in the fact that the search box is using the boxes class and therefor will look like a box. The easiest way is to create a regular html form (with exisitng osC tech) in your header where you want the search:

 

Not tested, from the top of my head:

 

<?php

$hide = tep_hide_session_id();

echo '<form name="quick_find" method="get" action="' . tep_href_link FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false) . '">';

echo $hide . '<input type="text" name="keywords" size="10" maxlength="30" value="' . htmlspecialchars(StripSlashes(@$HTTP_GET_VARS["keywords"])) . '"> ' . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . '<br>' . BOX_SEARCH_TEXT . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>' ;

echo '</form>';

?>

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

Thanks,

I'm getting this error, may be missing a comma or something

 

"Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /xx/xxx/public_html/shop/includes/header.php on line 26

 

"

This is line 26

echo '<form name="quick_find" method="get" action="' . tep_href_link FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false) . '">';

Link to comment
Share on other sites

Yes, that's possible

 

Site A has the form (without all the osC functions etc) and calls the advanced_search_results.php on your site (B).

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

You mean an adaption from advanced_search.php ?

So you can select WHERE it should search?

It basically the same method. Take the form bit from advanced_search.php and start throwing out what you don't need...

 

Or... the good old trick: Look at the rendered HTML page's SOURCE

to understand what's the output of the functions.

 

Mattice

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

  • 1 year later...

What's the BEST way to change the size and color of text in the search box? For example, I would like to make the "view all products" larger and red.

Link to comment
Share on other sites

  • 1 year later...
What's the BEST way to change the size and color of text in the search box?  For example, I would like to make the "view all products" larger and red.

 

This is a very old thread, but I am also in the process of inserting th esearch bar in my header and I am having an issue putting the actual search form as well as the "Search" image into the middle of the cell itself.

 

The image as well as search box is too far up and I'd like it to be in the middle opposed to the top. Anyone have any suggestions?

Link to comment
Share on other sites

  • 1 year later...

Hi all

 

I'm getting an error after performing the search

 

Fatal error: Cannot redeclare tep_show_category() (previously declared in /home/freeyour/www/includes/header.php:201) in /home/freeyour/www/includes/boxes/categories.php on line 13

 

What causes it and how do you resolve it?

 

Thanks in advance

Link to comment
Share on other sites

  • 6 months later...
What's the BEST way to change the size and color of text in the search box? For example, I would like to make the "view all products" larger and red.

 

I am trying to do this too, I cant figure out the php coding for box width in includes/boxes/search.php

Link to comment
Share on other sites

I found how to do it pretty easily, and if you want to align and width text boxes this is how:

 

find in manufacturers box or search box.....

$info_box_contents[] = array('form' => tep_draw_form

or something similar near the end where it says to draw the box, then youll see style=width etc and change it :lol:

 

and add/change ,'align' => 'center', if you want to center it

Link to comment
Share on other sites

  • 1 month later...

<?php
/*
 $Id: search.php,v 1.22 2003/02/10 22:31:05 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- search //-->
	  <tr>
		<td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_SEARCH);

 new infoBoxHeading($info_box_contents, false, false);

 $info_box_contents = array();
 $info_box_contents[] = array('form' => tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'),
						   'align' => 'center',
						   'text' => tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH-30) . 'px"') . ' ' . tep_hide_session_id() . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . '<br>' . BOX_SEARCH_TEXT . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>');

 new infoBox($info_box_contents);
?>
		</td>
	  </tr>
<!-- search_eof //-->

 

I would just like a simple search field and button, would I be able to alter the existing text to do so?

Link to comment
Share on other sites

  • 2 weeks later...

Thanks it worked this is what i added

 

<?php

$hide = tep_hide_session_id();

echo '<form name="quick_find" method="get" action="' . tep_href_link (FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false) . '">';

echo $hide . '<input type="text" name="keywords" size="10" maxlength="30" value="' . htmlspecialchars(StripSlashes(@$HTTP_GET_VARS["keywords"])) . '"> ' . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . '<br>' . BOX_SEARCH_TEXT . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>' ;

echo '</form>';

?>

Link to comment
Share on other sites

Hi! Please, advice me on this, I'm a newbie to both OSc and coding :'(

 

I've managed to tweak a bit, so my shop look lik this www.ji-fashion.com/butik

 

I have copied the code for languages etc and removed tags <tr> <td> tags naming the copies languages_header and so on.

Now I have a missaligment problem as you can see. What I would like to do is to change colors, box heights and width and

having the search just as a simple search. (The original search/advanced search box I will later insert in the right column).

 

I have searched in forums and found your advice on a similar question, and don't understand this piece:

 

style="width: ' . (BOX_WIDTH-30) . 'px"'

 

What does actually mean? Is okay to simply have it like this?

 

 

style="width: ' . (BOX_WIDTH-xyz) . 'px"'

 

where xyz is any number?

 

Hoping for your help

 

Best whishes from Sweden

 

Qim

Link to comment
Share on other sites

Hey gal... its like this. In an empty room, enjoy your company.. :-"

 

Well, I fixed most of it. Remaining is

 

How do I move languages and currencies to the headers far right? I'm lost in header.php

 

Talking to myself where are all the nice people who know the solution to this??? :blink:

 

Best whishes from Sweden

 

Qim

Link to comment
Share on other sites

From header.php:

<table border="0" width="100%" cellspacing="0" cellpadding="0" height="125">
<tr class="header">
<td align="right" valign="bottom" bgcolor="#0099ff" class="search" background="/images/longlogo.png">
<?php echo tep_draw_form('search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get') . tep_draw_hidden_field('search_in_description','1') . tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH+10) . 'px"') . ' ' . tep_hide_session_id() .'<input type="submit" name="Submit" value="Search">' . '</form>'; ?>
<br><br> <?php echo $breadcrumb->trail(' » '); ?>           <br><br>
</td>
</tr>
</table>

 

It's been so long since I implemented this that I don't remeber the source to credit.

See how it looks at my site: Hot Shot Magic

Link to comment
Share on other sites

  • 5 weeks later...

using this code

<?php
$hide = tep_hide_session_id();
echo '<form name="quick_find" method="get" action="' . tep_href_link (FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false) . '">';
echo $hide . '<input type="text" name="keywords" size="10" maxlength="30" value="' . htmlspecialchars(StripSlashes(@$HTTP_GET_VARS["keywords"])) . '"> ' . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH) . '<br>' . BOX_SEARCH_TEXT . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>';
echo '</form>';
?>

What do I take out to not have the words use advance keywords for your search

Link to comment
Share on other sites

  • 1 month later...

Just adding that I implemented this code and it works great. Here is a snapshot of the first table in the header tag. (this is from the default oscommerce load, hence the oscommerce.gif still there)

 

<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr class="header">
<td valign="middle"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . '</a>'; ?></td>
<td align="right" valign="middle" class="search">
<?php echo tep_draw_form('search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get') . tep_draw_hidden_field('search_in_description','1') . tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH+10) . 'px"') . ' ' . tep_hide_session_id() .'<input type="submit" name="Submit" value="Search">' . '</form>'; ?>
 </tr>
</table>

Link to comment
Share on other sites

  • 3 weeks later...

Thanks heaps, this works a charm. I was in all sorts of trouble before I got to this post.

 

Just adding that I implemented this code and it works great. Here is a snapshot of the first table in the header tag. (this is from the default oscommerce load, hence the oscommerce.gif still there)

 

<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr class="header">
<td valign="middle"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . '</a>'; ?></td>
<td align="right" valign="middle" class="search">
<?php echo tep_draw_form('search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get') . tep_draw_hidden_field('search_in_description','1') . tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH+10) . 'px"') . ' ' . tep_hide_session_id() .'<input type="submit" name="Submit" value="Search">' . '</form>'; ?>
 </tr>
</table>

Link to comment
Share on other sites

  • 3 weeks later...

<td align="right" valign="top"><form name="search" action="http://www.yoursite.com/catalog/advanced_search_result.php" method="get"><input type="hidden" name="search_in_description" value="1"><input type="text" name="keywords" size="10" maxlength="30" style="width: 100px"> <input type="image" src="includes/languages/english/images/buttons/button_search.gif" border="0" alt="BOX_HEADING_ADVSEARCH" title=" BOX_HEADING_ADVSEARCH " align="middle"></form></td>

 

I put this code directly into my sts template to get it to work. You have to edit the "yoursite" to match your url.

 

A demo of this can be seen at www.raysebookshop. com

Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...