Jump to content



Photo
- - - - -

Search box in header navigation bar


This topic has been archived. This means that you cannot reply to this topic.
33 replies to this topic

#1   Tasker

Tasker
  • Members
  • 11 posts

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

enigma1
  • Members
  • 8,206 posts

Posted 27 March 2006 - 01:06

there is already a contribution about it.
http://www.oscommerc...tributions,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

Tasker
  • Members
  • 11 posts

Posted 29 March 2006 - 07:19

there is already a contribution about it.
http://www.oscommerc...tributions,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

Stargater07
  • Members
  • 86 posts

Posted 13 April 2006 - 12:24

Looks good on my site http://www.devonligh...talog/index.php

Thanks for the code.

Jason
Jason  :)

#5   ChrisTheGrant

ChrisTheGrant
  • Members
  • 21 posts

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

insomniac2
  • Members
  • 407 posts

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

triaxis
  • Members
  • 5 posts

Posted 24 May 2006 - 07:12

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

John2b
  • Members
  • 178 posts

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

bharti
  • Members
  • 32 posts

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


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

pdcelec
  • Members
  • 606 posts

Posted 22 January 2011 - 22:23

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

bharti
  • Members
  • 32 posts

Posted 23 January 2011 - 08:10

similar to zcom.co.nz

similar to this ?
www.electricalcity.co.uk



#12   bharti

bharti
  • Members
  • 32 posts

Posted 27 January 2011 - 19:41

could i please get some help on this... this is forum and no reply /sad.gif' class='bbc_emoticon' alt=':(' />

#13   WallaceNetworks.co.uk

WallaceNetworks.co.uk
  • Members
  • 12 posts

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

germ
  • Members
  • 13,921 posts

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.gif' class='bbc_emoticon' alt=':blush:' />
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"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

WallaceNetworks.co.uk
  • Members
  • 12 posts

Posted 16 February 2011 - 00:29

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.gif' class='bbc_emoticon' alt=':blush:' />


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

Many thanks!

#16   wayne miller

wayne miller
  • Members
  • 35 posts

Posted 18 August 2011 - 23:08

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.gif' class='bbc_emoticon' alt=':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.gif' class='bbc_emoticon' alt=':thumbsup:' /> Do I need to alter the code above or make another change elsewhere?

Thanks in advance Wayne

#17 ONLINE   kymation

kymation

    Code Monkey

  • Community Sponsor
  • 8,026 posts

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 Download Support
Categories Accordion Box Download Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box Download Support
Get 1 Free 2.2x Support
Price in Cart Only/MAPP Download Support
Modular Front Page Download Support
Modular SEO Header Tags Download Support
MVS 2.2x Support
PDF Datasheet Download Support
Price Updater 2.2x
Products Specifications 2.3.x Development Version Support Bugs/Suggestions
Request a Review Download Support

Shopping List Download Support New!
Specials Image Overlay Download Support
Superfish Categories Box Download Support
Theme Switcher 2.3+ Support  Updated


#18   wayne miller

wayne miller
  • Members
  • 35 posts

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

wayne miller
  • Members
  • 35 posts

Posted 19 August 2011 - 00:34

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 ONLINE   kymation

kymation

    Code Monkey

  • Community Sponsor
  • 8,026 posts

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 Download Support
Categories Accordion Box Download Support
Closest Shipper 2.2x Support
Document Manager 2.2x Support
Generic Box Download Support
Get 1 Free 2.2x Support
Price in Cart Only/MAPP Download Support
Modular Front Page Download Support
Modular SEO Header Tags Download Support
MVS 2.2x Support
PDF Datasheet Download Support
Price Updater 2.2x
Products Specifications 2.3.x Development Version Support Bugs/Suggestions
Request a Review Download Support

Shopping List Download Support New!
Specials Image Overlay Download Support
Superfish Categories Box Download Support
Theme Switcher 2.3+ Support  Updated