Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Search box in header navigation bar


33 replies to this topic

#1 Tasker

  • Community Member
  • 11 posts
  • Real Name:Jack Stone

Posted 25 March 2006, 01:15

This will add a search box to the header navigation bar at the top of the page. If you like it you can disable the standard oscommerce search box by opening includes/column_left.php and adding 2 forward slashes before: require(DIR_WS_BOXES . 'search.php'); Thus: //require(DIR_WS_BOXES . 'search.php');

This works well on my site, may be different on yours, I have a header bar 22px high, this can be set in catalog/stylesheet.css under this setting: TD.headerNavigation

So Backup and open catalog/includes/header.php

Find:

<table border="0" width="100%" cellspacing="0" cellpadding="1">
  <tr class="headerNavigation">
	<td class="headerNavigation">  <?php echo $breadcrumb->trail(' » '); ?></td>

Change the cellpadding to "0"

Add the following after the above code:

<script type="text/javascript" language="JavaScript1.2">
					<!--
						function clearThis(it){
							it.value = "";
						}
					//-->
					</script>
<td class="headerNavigation" align="right" valign="top"><form name="quick_find" method="get" action="/catalog/advanced_search_result.php">
<input type="text" 
name="keywords" size="15" maxlength="50" style="width: 110px" value="Search..." onFocus="clearThis(this);" style="width: 90px">
<input type="image" src="includes/languages/english/images/buttons/button_quick_find.gif" alt="Quick Find" title="Quick Find">
<input type="checkbox" name="search_in_description" alt="Search in descriptions" title="Search in descriptions" value="1">Keywords  
</form>

So BACKUP FIRST and see if it pleases you or not. It includes a "search in description" checkbox.
Have fun!

#2 enigma1

  • Community Member
  • 8,206 posts
  • Real Name:Mark Samios

Posted 27 March 2006, 01:06

there is already a contribution about it.
http://www.oscommerce.com/community/contributions,3295

also your code will not work with sessions as you do not use the osc functions to preserve it.

and jscript functions should be included wihin the html head section

#3 Tasker

  • Community Member
  • 11 posts
  • Real Name:Jack Stone

Posted 29 March 2006, 07:19

View Postenigma1, on Mar 27 2006, 01:06 PM, said:

there is already a contribution about it.
http://www.oscommerce.com/community/contributions,3295

also your code will not work with sessions as you do not use the osc functions to preserve it.

and jscript functions should be included wihin the html head section

There may be a contribution, but it's probably more work than my suggestion. The jscript works fine where it
is, I don't use sessions so that never occurred to me, anyone is welcome to modify the code, I offered it
as a plugnplay solution. But I appreciate your concerns.

#4 Stargater07

  • Community Member
  • 86 posts
  • Real Name:Jason
  • Location:Torquay

Posted 13 April 2006, 12:24

Looks good on my site http://www.devonlightingcentre.net/catalog/index.php

Thanks for the code.

Jason
Jason :)

#5 ChrisTheGrant

  • Community Member
  • 21 posts
  • Real Name:Chris Grant

Posted 23 May 2006, 14:22

Hi,
I have just installed it on my site, and it looks fine, but when i click on the search icon it doesn't work and returns an HTTP 404 error (Page not found).

If anyone can help me to resolve this i would appreciate it. My site is:
car-puters.com

Thanks,
Chris

#6 insomniac2

  • Community Member
  • 407 posts
  • Real Name:Don

Posted 23 May 2006, 21:12

Example:

<tr>
<td class="smallText" valign="bottom" colspan="0">

&nbsp;&nbsp;&nbsp;<?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '">' . TEXT_ENTER_KEYWORDS . '</a>'; php echo TEXT_CHOOSE_CATEGORY; ?>
<?php echo tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get') . tep_hide_session_id(); ?>

<table background="images/backgrounds/toolbar_haze.gif" align="center" width="98%" border="0" cellspacing="0" cellpadding="0">

<tr>
<td valign="middle">&nbsp;</td>

<td valign="middle"><?php echo tep_draw_hidden_field('search_in_description', '1') . tep_draw_hidden_field('inc_subcat', '1', true) . tep_draw_input_field('keywords', ' > Enter Keywords < ', 'onfocus="this.value=\'\'" size="10" maxlength="30" style="width: ' . (BOX_WIDTH+50) . 'px"'); ?>&nbsp;

<?php echo tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => BOX_ADVSEARCH_ALLCAT)))) . tep_hide_session_id(); ?></td>
</tr>

Edited by insomniac2, 23 May 2006, 21:12.


#7 triaxis

  • Community Member
  • 5 posts
  • Real Name:Jonathan

Posted 24 May 2006, 07:12

View PostChrisTheGrant, on May 23 2006, 10:22 AM, said:

Hi,
I have just installed it on my site, and it looks fine, but when i click on the search icon it doesn't work and returns an HTTP 404 error (Page not found).

If anyone can help me to resolve this i would appreciate it. My site is:
car-puters.com

Thanks,
Chris

Reason it wont work is because he has it set to work if your root oscommerce install folder is called "catalog"

you have to change it to your root folder name.

the code line is <form name="quick_find" method="get" action="/catalog/advanced_search_result.php">

change "/catalog/ to your oscommerce folder.

#8 John2b

  • Community Member
  • 178 posts
  • Real Name:John M
  • Location:Schiedam Netherlands

Posted 23 June 2006, 11:13

I add this search box to my header, but beside it I want to add the drop down list with the Manufacturers.

But for some reason I can't get it work? anyone give me a hint...
A friendship founded on business is better than a business founded on friendship

#9 bharti

  • Community Member
  • 32 posts
  • Real Name:bharti

Posted 22 January 2011, 10:14

Hi,

I am trying to do the same (move the search box to header navigation bar) in oscommerce 2.3.1 but it is not working... could any please advise how to do this in 2.3 version?

Thanks
Bharti


View PostJohn2b, on 23 June 2006, 11:13, said:

I add this search box to my header, but beside it I want to add the drop down list with the Manufacturers.

But for some reason I can't get it work? anyone give me a hint...


#10 pdcelec

  • Community Member
  • 606 posts
  • Real Name:Paul Clifford
  • Gender:Male
  • Location:UK

Posted 22 January 2011, 22:23

View Postbharti, on 22 January 2011, 10:14, said:

Hi,

I am trying to do the same (move the search box to header navigation bar) in oscommerce 2.3.1 but it is not working... could any please advise how to do this in 2.3 version?

Thanks
Bharti
similar to this ?
www.electricalcity.co.uk

Edited by Jan Zonjee, 23 January 2011, 07:51.


#11 bharti

  • Community Member
  • 32 posts
  • Real Name:bharti

Posted 23 January 2011, 08:10

similar to zcom.co.nz

View Postpdcelec, on 22 January 2011, 22:23, said:

similar to this ?
www.electricalcity.co.uk


#12 bharti

  • Community Member
  • 32 posts
  • Real Name:bharti

Posted 27 January 2011, 19:41

could i please get some help on this... this is forum and no reply :(

#13 WallaceNetworks.co.uk

  • Community Member
  • 8 posts
  • Real Name:Allan Wallace
  • Gender:Male

Posted 13 February 2011, 14:35

I have a similar problem with search in the header.php

Well, i says similar...

Basicly, I have altered my header.php so instead of having this code at the start:


<?php
/*
$Id$

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

Copyright © 2010 osCommerce

Released under the GNU General Public License
*/

if ($messageStack->size('header') > 0) {
echo '<div class="grid_24">' . $messageStack->output('header') . '</div>';
}
?>
<div id="header" class="grid_24">
<div id="storeLogo"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'company_logo.gif', STORE_NAME) . '</a>'; ?></div>
<div id="headerShortcuts">
<?php
echo tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');
echo '<strong>Search Site:</strong> ' . tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: 100px"') . ' ' . tep_hide_session_id() . tep_draw_hidden_field('search_in_description', '1') . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH);
}
?> &nbsp&nbsp
<?php
echo tep_draw_button(HEADER_TITLE_CART_CONTENTS . ($cart->count_contents() > 0 ? ' (' . $cart->count_contents() . ')' : ''), 'cart', tep_href_link(FILENAME_SHOPPING_CART)) .
tep_draw_button(HEADER_TITLE_CHECKOUT, 'triangle-1-e', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')) .
tep_draw_button(HEADER_TITLE_MY_ACCOUNT, 'person', tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));

if (tep_session_is_registered('customer_id')) {
echo tep_draw_button(HEADER_TITLE_LOGOFF, null, tep_href_link(FILENAME_LOGOFF, '', 'SSL'));
}
?>
</div>



I now have the following:


<?php
/*
$Id$

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

Copyright © 2010 osCommerce

Released under the GNU General Public License
*/

if ($messageStack->size('header') > 0) {
echo '<div class="grid_24">' . $messageStack->output('header') . '</div>';
}
?>
<div id="header" class="grid_24">
<div id="storeLogo"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'company_logo.gif', STORE_NAME) . '</a>'; ?></div>
<div id="headerShortcuts">
<?php
echo tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');
echo '<strong>Search Site:</strong> ' . tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: 100px"') . ' ' . tep_hide_session_id() . tep_draw_hidden_field('search_in_description', '1') . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH);
?>&nbsp&nbsp
<?php
echo tep_draw_button(HEADER_TITLE_CART_CONTENTS . ($cart->count_contents() > 0 ? ' (' . $cart->count_contents() . ')' : ''), 'cart', tep_href_link(FILENAME_SHOPPING_CART)) .
tep_draw_button(HEADER_TITLE_CHECKOUT, 'triangle-1-e', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')) .
tep_draw_button(HEADER_TITLE_MY_ACCOUNT, 'person', tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));

if (tep_session_is_registered('customer_id')) {
echo tep_draw_button(HEADER_TITLE_LOGOFF, null, tep_href_link(FILENAME_LOGOFF, '', 'SSL'));
}
?>
</div>



And the search box itself works fine,


BUT (and this is a bit of a problem) If i got to view a product in the catalog, i can add it from the catalog category view page, but when i select the individual product view page, the "Add to Cart" button tries to do Advanced search instead.

Anyone got any ideas?

Thanks in advance.

#14 germ

  • Community Member
  • 13,581 posts
  • Real Name:Jim
  • Gender:Male
  • Location:USA (GMT-6)

Posted 13 February 2011, 14:47

Your <form...> </form> tags are screwed.

You have to close one form before opening another.

When the results from one form are passed to another this is always the case.

Look at the HTML source and search for the <form...> </form> tags.

If you have two <form...> tags in succession without an intervening </form> tag - there's the problem.

I think there is some mechanism in osC that's supposed to supply the closing form tag, but sometimes you have to "brute force" them in.
:blush:
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#15 WallaceNetworks.co.uk

  • Community Member
  • 8 posts
  • Real Name:Allan Wallace
  • Gender:Male

Posted 16 February 2011, 00:29

View Postgerm, on 13 February 2011, 14:47, said:

Your <form...> </form> tags are screwed.

You have to close one form before opening another.

When the results from one form are passed to another this is always the case.

Look at the HTML source and search for the <form...> </form> tags.

If you have two <form...> tags in succession without an intervening </form> tag - there's the problem.

I think there is some mechanism in osC that's supposed to supply the closing form tag, but sometimes you have to "brute force" them in.
:blush:

Thank you so much for your help, you were absolutely spot-on with your advice.

Many thanks!

#16 wayne miller

  • Community Member
  • 35 posts
  • Real Name:Wayne Miller

Posted 18 August 2011, 23:08

View Postgerm, on 13 February 2011, 14:47, said:

Your <form...> </form> tags are screwed.

You have to close one form before opening another.

When the results from one form are passed to another this is always the case.

Look at the HTML source and search for the <form...> </form> tags.

If you have two <form...> tags in succession without an intervening </form> tag - there's the problem.

I think there is some mechanism in osC that's supposed to supply the closing form tag, but sometimes you have to "brute force" them in.
:blush:

Hi there,

Im completely new to all of this and loving it already !!!!!

Ive just updated my header.php with the code below that Allan supplied to get a search box in my header:

<?php
/*
$Id$

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

Copyright © 2010 osCommerce

Released under the GNU General Public License
*/

if ($messageStack->size('header') > 0) {
echo '<div class="grid_24">' . $messageStack->output('header') . '</div>';
}
?>
<div id="header" class="grid_24">
<div id="storeLogo"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'company_logo.gif', STORE_NAME) . '</a>'; ?></div>
<div id="headerShortcuts">
<?php
echo tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');
echo '<strong>Search Site:</strong> ' . tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: 100px"') . ' ' . tep_hide_session_id() . tep_draw_hidden_field('search_in_description', '1') . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH);
?>&nbsp&nbsp
<?php
echo tep_draw_button(HEADER_TITLE_CART_CONTENTS . ($cart->count_contents() > 0 ? ' (' . $cart->count_contents() . ')' : ''), 'cart', tep_href_link(FILENAME_SHOPPING_CART)) .
tep_draw_button(HEADER_TITLE_CHECKOUT, 'triangle-1-e', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')) .
tep_draw_button(HEADER_TITLE_MY_ACCOUNT, 'person', tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));

if (tep_session_is_registered('customer_id')) {
echo tep_draw_button(HEADER_TITLE_LOGOFF, null, tep_href_link(FILENAME_LOGOFF, '', 'SSL'));
}
?>
</div>

I am now obviously getting the same problem as Allen did.

I can see by your response that the form tags are screwed but what exactly does that mean? rembember Im completely new to this, I do pick things up pretty quickly though so please be gentle for a little while :thumbsup: Do I need to alter the code above or make another change elsewhere?

Thanks in advance Wayne

#17 kymation

  • Community Sponsor
  • 5,657 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 19 August 2011, 00:12

Most HTML tags have to match. That is, for every <form> there must be a closing </form>. In the code you posted, tep_draw_form() draws the opening <form> tag. You don't have any closing </form> tag, so you need to add that at the end of the part you posted in bold above.

You can see the tags by viewing the page in your browser and selecting "View Page Source." The Firebug addon in Firefox is also very good at showing things like this, and lets you try fixes without changing the source code.

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support

#18 wayne miller

  • Community Member
  • 35 posts
  • Real Name:Wayne Miller

Posted 19 August 2011, 00:31

<?php
echo tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get');
echo '<strong>Search Site:</strong> ' . tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: 100px"') . ' ' . tep_hide_session_id() . tep_draw_hidden_field('search_in_description', '1') . tep_image_submit('button_quick_find.gif', BOX_HEADING_SEARCH);
?>&nbsp&nbsp</form>

Simples,

Thanks a million Jim

I love this stuff! gotta go to bed, work in the morning and its now 01:30am tee hee, thanks again for the advice

#19 wayne miller

  • Community Member
  • 35 posts
  • Real Name:Wayne Miller

Posted 19 August 2011, 00:34

View Postkymation, on 19 August 2011, 00:12, said:

You can see the tags by viewing the page in your browser and selecting "View Page Source." The Firebug addon in Firefox is also very good at showing things like this, and lets you try fixes without changing the source code.

Regards
Jim

No way! thats sounds too easy. So if I download the Firebug addon I can look at the code on any website?

#20 kymation

  • Community Sponsor
  • 5,657 posts
  • Real Name:Jim Keebaugh
  • Gender:Male
  • Location:Aberdeen WA USA

Posted 19 August 2011, 01:21

Yes, Firebug will let you look at and change the code on any website. Only in your own browser, of course, but it's handy to check out bits of code to see what they do.

Regards
Jim
My Addons

Banners Box 2.3.1 Support
Categories Accordion Box 2.3.1 Support
Categories Images Box 2.2x 2.3.1 Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box 2.3.1 Support
Get 1 Free 2.2x Support
Include HTML and Text Boxes 2.2x
jQuery Banner Rotator 2.2x 2.3.1 Support
Modular Front Page 2.3.1 Support
Modular SEO Header Tags 2.3.1 Support
More Pics 2.2x Support
MVS 2.2x Support
osC Catalog 2.2x Support
PDF Datasheet 2.3.1 Support
Price Updater 2.2x
Products Specifications 2.2x 2.3.1 Development Version Support Bugs/Suggestions
Request a Review 2.2x - 2.3.1 Support
Similar Products Box 2.2x
Theme Switcher 2.3.1 Support