PDA

View Full Version : Where is Search.php?



glennf
06-11-2010, 07:19 PM
Most themes have a SEARCH.PHP file. I need to modify the code to return E-Bay Listings instead of posts.

Where is search code when someone enters text in the search box?

Dan Nickerson
06-12-2010, 11:15 PM
Glenn, here's a thread that answers you question. It's in header.php

http://www.socratestheme.com/forum/showthread.php?t=20

glennf
06-13-2010, 06:40 AM
Thanks Dan,

This is the FORM code. I need to know where the actual form processing is when the user type in a search query and presses the button.

Can you tell me where that is?

Dan Nickerson
06-13-2010, 10:16 AM
Glenn,

Correct that is the form code. And if you wish to add an ebay search function you would replace the form path with your ebay search action url.

If you want to get into Wordpress core files I would not recommend it.

If you are looking to create a custom search results page and then integrate ebay into that here's a tutorial on how to do that...

http://codex.wordpress.org/Creating_a_Search_Page#Customizing_Your_Search_Pag e

It might be easier if you just include the code that Ebay is giving you so we can better understand what you're trying to achieve.

glennf
06-13-2010, 12:00 PM
Here is the code I am using for the search results:

<p align="center">Your search for '<strong><font color="#FF0000"><? echo $_GET["s"] ?></font></strong>' returned the following results:</p>
<p>
<?php
function phpBaySearch($term) {
$keyword = $term;
$category = "";
$text .= '' . $keyword . ',20,' . $category . ', ""';
echo phpBayPro($text);
}
phpBaySearch($_GET["s"]);
?>

<?php
function phpZonsearch($term) {
$keywords = $term;
$text .= '[phpzon keywords="'.$keywords.'" num="10" country="US" searchindex="All" templatename="default" paging="true"]';
echo do_shortcode($text);
}
phpZonsearch($_GET["s"]);
?>
</p>

Can you tell what to change in the FORM code as far as the URL?

Dan Nickerson
06-13-2010, 12:30 PM
Can you provide a resource where you're getting this code from? I'm sure they must have tutorials and more information.

Can you set this up on Wordpress's default theme?

I have to sign off for a couple of hours.. I only work 12 hours on Sundays, but will be back later this afternoon.

glennf
06-13-2010, 01:33 PM
Here is the searchform.php and search.php where this code works. The theme is Atahualpa 3.2 at this URL http://wordpress.bytesforall.com.

Please look at it and tell me how to modify the Socrates them to do the same thing.


SEARCHFORM.PHP

<form method="get" class="searchform" action="<?php bloginfo('url'); ?>/">
<table class="searchform" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="searchfield">
<input type="text" class="text inputblur" value="<?php the_search_query(); ?>" name="s" />
</td>
<td class="searchbutton">
<input name="submit" value="Search" type="image" src="<?php echo get_bloginfo('template_directory'); ?>/images/magnifier2-gray.gif" style="display: block; border:none; padding: 0 0 0 5px; margin: 0;" />
</td>
</tr></table>
</form>


SEARCH.PHP

<?php
global $options;
foreach ($options as $value) {
if (get_option( $value['id'] ) === FALSE) {
$$value['id'] = $value['std'];
} else {
$$value['id'] = get_option( $value['id'] );
}
}
if ( is_page() ) { global $wp_query; $current_page_id = $wp_query->get_queried_object_id(); }
?>
<?php get_header(); ?>

<!--p align="center">Your search for '<strong><font color="#FF0000"><? echo $_GET["s"] ?></font></strong>' returned the following results:</p-->

<p align="center">Your search for '<strong><font color="#FF0000"><? echo $_GET["s"] ?></font></strong>' returned the following results:</p>
<p>
<?php
function phpBaySearch($term) {
$keyword = $term;
$category = "";
$text .= '' . $keyword . ',20,' . $category . ', ""';
echo phpBayPro($text);
}
phpBaySearch($_GET["s"]);
?>

<?php
function phpZonsearch($term) {
$keywords = $term;
$text .= '[phpzon keywords="'.$keywords.'" num="10" country="US" searchindex="All" templatename="default" paging="true"]';
echo do_shortcode($text);
}
phpZonsearch($_GET["s"]);
?>
</p>

<?php get_footer(); ?>

Dan Nickerson
06-13-2010, 05:53 PM
Glenn,

This is a little beyond the scope of support for the theme, but here's what I tried to do.

I replaced the form we first discussed in this thread with the searchform.php file.

And I saved the search.php file to my desktop and then FTP'd it into the Socrates folder with the other theme files.

Then I tested it and got this error.

Fatal error: Call to undefined function phpbaypro() in /home/socrates/public_html/beta/wp-content/themes/socrates/search.php on line 23

When Googling this error there's actually 378 results... so it's pretty common problem.

And then of course I discovered PHPBayPro is a plugin which you never mentioned.. and which would have made things a lot easier. (and saved 30 minutes of my day)

Do you have the plugin installed?

That and the above are probably what you need to make it work.

glennf
06-13-2010, 08:17 PM
Yes. I hae the plug-in installed. It's requires a license so that probably why you got that error.

Can you tell what I need to do?

So you copied my code into searchform.php and search.php respectively and uploaded them to the socrates folder?

What about the form code in your header.php, what do you do with that?

glennf
06-13-2010, 08:44 PM
Glenn,

This is a little beyond the scope of support for the theme, but here's what I tried to do.

I replaced the form we first discussed in this thread with the searchform.php file.

And I saved the search.php file to my desktop and then FTP'd it into the Socrates folder with the other theme files.

Then I tested it and got this error.

Fatal error: Call to undefined function phpbaypro() in /home/socrates/public_html/beta/wp-content/themes/socrates/search.php on line 23

When Googling this error there's actually 378 results... so it's pretty common problem.

And then of course I discovered PHPBayPro is a plugin which you never mentioned.. and which would have made things a lot easier. (and saved 30 minutes of my day)

Do you have the plugin installed?

That and the above are probably what you need to make it work.
OK. I think I get it. I replaced the FORM code in your header.php with the searchform.php code and uploaded the code in SEARCH.PHP to the socrates folder. I get this warning: Warning: Invalid argument supplied for foreach() in /home/tsfl/public_html/talkingsoccer.net/wp-content/themes/socrates/search.php on line 3
And the EBay, Amazon listings display but they take over the whole page instead of being in the center column. Here is the URL: talkingsoccer.net

What can I do to fix this?

Dan Nickerson
06-13-2010, 10:05 PM
Glenn,

You should contact someone whose worked with their plugin before, and check their online resources.

They must have support for this plugin if they want you to jump through these kind of hoops to set it up.

I would really like to help, but with 1000's of Socrates customers I've got to focus my time on Socrates related issues. Please check with PHPBayPro support.

glennf
06-14-2010, 09:45 AM
OK. I contacted the plug-ins admin and I got it to work with Socrates. The only thing missing is the little horizontal dashes accross the bottom of the page or any page. Can you tell me what code in SINGLE.PHP I would need to use in my search file to put those dashes in (i.e. =========) ?

Dan Nickerson
06-14-2010, 10:21 AM
Can you give a example link? Are you saying you want dashes on every single post or page in Socrates or just on your new search page?

For all pages it would be controlled by the style.css folder. You would need to add a border bottom to post entries.

Depending on how you want this to appear, it might be just as easy to hard code it into a page. <p>=========================================</p> inside the page code.

jv63
07-01-2010, 05:51 PM
OK. I contacted the plug-ins admin and I got it to work with Socrates. The only thing missing is the little horizontal dashes accross the bottom of the page or any page. Can you tell me what code in SINGLE.PHP I would need to use in my search file to put those dashes in (i.e. =========) ?

Can you tell me how you got the search using phpBay and phpZon to work? Been trying to get it to work myself but to no avail.

Thanks

glennf
07-01-2010, 08:00 PM
Been meaning to document this for my next site using phpBay/phpZon. Here you go. Check out my Soccer Site (http://www.talkingsoccer.net/) and see how you like it! Do a search for soccer stuff and buy something it you like. :D

Replace the <form> code as shown below in HEADER.PHP

<!-- Search Form -->
<div id="im-searchForm">
<form method="get" class="searchform" action="<?php bloginfo('url'); ?>/">
<table class="searchform" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="searchfield">
<input type="text" class="text inputblur" value="<?php the_search_query(); ?>" name="s" />
</td>
<td class="searchbutton">
<input name="submit" value="Search" type="image" src="<?php echo get_bloginfo('template_directory'); ?>/images/search.png" />
</td>
</tr></table>
</form>
<!--OLD FORM -->
<!--form method="GET" action="<?php bloginfo('home'); ?>/">
<input type="text" name="s" class="searchBox" id="s"
onblur="this.value=(this.value=='') ? 'search' : this.value;"
onfocus="clearText(this);" value="" />
<input type="image" id="searchBtn" name="searchBtn"
src="<?php bloginfo('template_url'); ?>/images/search.png"
onmouseover="this.src='<?php bloginfo('template_url'); ?>/images/searchOv.png'"
onmouseout="this.src='<?php bloginfo('template_url'); ?>/images/search.png'" border="0" />
</form-->
</div>

ADD a NEW FILE CALLED search.php and put in your socrates template folder and add this code to it. Just change the amount of results for phpBay/phpZon you want.

<?php get_header();
include "topAd.php";
include "sidebar.php";
include "sidebar2.php";
?>

<?php if (have_posts()) : ?>

<div id="im-mainContent" class="im-mainContent">

<p align="center">Your search for '<strong><font color="#FF0000"><? echo $_GET["s"] ?></font></strong>' returned the following results:</p>
<p>
<?php
function phpBaySearch($term) {
$keyword = $term;
$category = "";
$text .= '' . $keyword . ',20,' . $category . ', ""';
echo phpBayPro($text);
}
phpBaySearch($_GET["s"]);
?>

<?php
function phpZonsearch($term) {
$keywords = $term;
$text .= '[phpzon keywords="'.$keywords.'" num="10" country="US" searchindex="All" templatename="default" paging="true"]';
echo do_shortcode($text);
}
phpZonsearch($_GET["s"]);
?>
</p>

</div>

<?php endif; ?>

<div class="line"></div>

<?php get_footer(); ?>

jv63
07-01-2010, 08:27 PM
That is awesome. Thanks so much. That's like that missing piece to having my sites the way I want them to look and act.

jv63
07-05-2010, 08:24 AM
Hi Glenn,

Made some modifications to your script that you might be interested in. Someone pointed out to me that they sometimes got search results and sometimes a blank page.

It's because of these two lines that need to be removed:

<?php if (have_posts()) : ?>

<?php endif; ?>


Secondly, I found out that by having searchindex="ALL" you only get 5 pages of results. Even though it will show many more, once you click on page 6 you will get an error message. If you use a search index other than ALL you will get all the pages.

Cheers

Jay

ssheldon
07-25-2010, 10:48 AM
Great mod! Thanks...

This may be asking too much but is there anyway to pull in posts/articles in the search also?

Like on your soccer site Glenn, you have an article on Court Soccer. If someone searched for court soccer shouldn't that article come up with the listings under it. If a search is done where there are no posts/articles, then it would default to the current mod.

Otherwise, the only way I can see to do this would be to have a separate search bar for the articles.

Any input or ideas?

Thanks!

Sue