Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Editing the Search Result Page?

Editing the Search Result Page?

Locked

Views: 1,873

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
9 Mar 2009, 5:27 PM
#1
jsnacker avatar

jsnacker

New Zenner

Join Date:
Feb 2009
Posts:
37
Plugin Contributions:
0

Editing the Search Result Page?

Does anyone know how to edit the search result page? I'd like to have whatever is searched for (such as "pistachio") to be echo'd and outputted to the pages Title, and within the body of the text.

Any help would be greatly appreciated! :clap:

9 Mar 2009, 7:24 PM
#2
jwitt98 avatar

jwitt98

New Zenner

Join Date:
Feb 2009
Posts:
95
Plugin Contributions:
0

Re: Editing the Search Result Page?

Try putting:

<?php echo $sData['keyword']; ?>

Where you want the keyword to appear.

9 Mar 2009, 9:41 PM
#3
jsnacker avatar

jsnacker

New Zenner

Join Date:
Feb 2009
Posts:
37
Plugin Contributions:
0

Re: Editing the Search Result Page?

Thanks for the help. I've tried inserting it, but it's giving me some php error... But...

I've narrowed the search page to this...

/includes/languages/english/advanced_search_result.php

define('NAVBAR_TITLE_1', 'Advanced Search');
define('NAVBAR_TITLE_2', 'Search Results');

//define('HEADING_TITLE_1', 'Advanced Search');
define('HEADING_TITLE', 'Advanced Search');

How can i get that variable inside the single quotes?

10 Mar 2009, 12:08 AM
#4
jwitt98 avatar

jwitt98

New Zenner

Join Date:
Feb 2009
Posts:
95
Plugin Contributions:
0

Re: Editing the Search Result Page?

I was actually thinking more along these lines:
In \includes\templates\CUSTOM\templates\tpl_advanced_search_default.php
Where CUSTOM is your custom template name,
replace

<h1 id="advSearchDefaultHeading"><?php echo HEADING_TITLE_1; ?></h1>

with

<h1 id="advSearchDefaultHeading"><?php echo $sData['keyword']; ?></h1>

You could also add your custom text in front like this:

<h1 id="advSearchDefaultHeading">This is the term you searched for: <?php echo $sData['keyword']; ?></h1>
10 Mar 2009, 5:14 PM
#5
jsnacker avatar

jsnacker

New Zenner

Join Date:
Feb 2009
Posts:
37
Plugin Contributions:
0

Re: Editing the Search Result Page?

Ahh! I'm starting to see how Zencart works now... Thank you so much for your help.

So I replaced

<h1 id="advSearchResultsDefaultHeading"><?php echo HEADING_TITLE; ?></h1>

with:

<h1 id="advSearchDefaultHeading">Search results for: <?php echo $sData['keyword']; ?></h1>

but the HTML output is only:

<h1 id="advSearchDefaultHeading">Search results for: </h1>

Any reason why it wouldn't get passed through? :frusty:

10 Mar 2009, 11:19 PM
#6
jwitt98 avatar

jwitt98

New Zenner

Join Date:
Feb 2009
Posts:
95
Plugin Contributions:
0

Re: Editing the Search Result Page?

Hmm, That strage. It works OK on my site:
It seems for some reason your $sData array has not been assigned a value yet. Maybe try replacing $sData with $_GET like this:

<h1 id="advSearchDefaultHeading">Search Results For: <?php echo $_GET['keyword']; ?></h1>

$_GET['keyword'] should work as long as the keyword is present in the url of the page.

11 Mar 2009, 1:14 AM
#7
jwitt98 avatar

jwitt98

New Zenner

Join Date:
Feb 2009
Posts:
95
Plugin Contributions:
0

Re: Editing the Search Result Page?

You may also want to edit:
\includes\templates\CUSTOM\templates\tpl_advanced_search_result_default.php
as well as:
\includes\templates\CUSTOM\templates\tpl_advanced_search_default.php

The first displays the search results, the second displays the default search page.

11 Mar 2009, 6:36 PM
#8
jsnacker avatar

jsnacker

New Zenner

Join Date:
Feb 2009
Posts:
37
Plugin Contributions:
0

Re: Editing the Search Result Page?

jwitt98:

Hmm, That strage. It works OK on my site:
It seems for some reason your $sData array has not been assigned a value yet. Maybe try replacing $sData with $_GET like this:

<h1 id="advSearchDefaultHeading">Search Results For: <?php echo $_GET['keyword']; ?></h1> ``` > $_GET['keyword'] should work as long as the keyword is present in the url of the page.

This is perfect and works flawlessly. Thank you so much! :clap:

The only issue now is getting that to the <title>.

12 Mar 2009, 1:03 AM
#9
jwitt98 avatar

jwitt98

New Zenner

Join Date:
Feb 2009
Posts:
95
Plugin Contributions:
0

Re: Editing the Search Result Page?

OK, the <title> tag requires a bit more work.
in:
\includes\modules\meta_tags.php
first make a backup of the file!
comment out the following lines:
case 'advanced_search':
case 'advanced_search_result':

directly under the line: switch ($_GET['main_page']) {
paste the following:

case 'advanced_search':
	define('META_TAG_TITLE', 'You Searched For: '.$_GET['keyword']);
	define('META_TAG_DESCRIPTION', TITLE . PRIMARY_SECTION . NAVBAR_TITLE_1 . SECONDARY_SECTION . KEYWORDS);
	define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . NAVBAR_TITLE_1);
	break;
	
	case 'advanced_search_result':
	define('META_TAG_TITLE', 'You Searched For: '.$_GET['keyword']);
	define('META_TAG_DESCRIPTION', TITLE . PRIMARY_SECTION . NAVBAR_TITLE_2 . SECONDARY_SECTION . KEYWORDS);
	define('META_TAG_KEYWORDS', KEYWORDS . METATAGS_DIVIDER . NAVBAR_TITLE_2);
	break;

Change "You Searched For: " to whatever you want it to read
Just make sure if you use any quotes in your wording to escape them.

12 Mar 2009, 7:08 PM
#10
jsnacker avatar

jsnacker

New Zenner

Join Date:
Feb 2009
Posts:
37
Plugin Contributions:
0

Re: Editing the Search Result Page?

Thank you so much! :bigups:

I'm impressed. How does one figure all of this out? I spent so much time searching includes for title tags and any variables to point to with no major results! :no: All I've learned so far is that Zen Cart is insanely huge and I've got a lot to learn! :)

Thanks again!

13 Mar 2009, 12:56 AM
#11
jwitt98 avatar

jwitt98

New Zenner

Join Date:
Feb 2009
Posts:
95
Plugin Contributions:
0

Re: Editing the Search Result Page?

Glad I could help.
I use Windows Grep for searching files. I've found it to be an invaluable tool for searching for text strings within many files at once.
The firebug add on for firefox is another invaluable tool. It allows you to inspect and temporarily modify your html and css directly from the browser window.

13 Mar 2009, 9:57 PM
#12
jsnacker avatar

jsnacker

New Zenner

Join Date:
Feb 2009
Posts:
37
Plugin Contributions:
0

Re: Editing the Search Result Page?

I'll definitely check out GERP.

How is Firebug? I've used Web Developer Toolbar.

14 Mar 2009, 4:48 AM
#13
jwitt98 avatar

jwitt98

New Zenner

Join Date:
Feb 2009
Posts:
95
Plugin Contributions:
0

Re: Editing the Search Result Page?

one thing to remember about Grep:
when performing a search using special characters such as $ or <,
they have to be escaped properly like so:
$ and <
If your search result come up empty, it's likely because a special character was not escaped.
I use firebug primarily. I have not used Web Developer Toolbar, so I really can't compare the two.