Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2012, 07:03:55 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155522 Posts in 21712 Topics by 7760 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Add php-code to search results footer  (Read 947 times)
vanbemmel

Offline Offline

Posts: 22


« on: July 14, 2009, 11:52:59 AM »

Hello,
i would like to add the following php-code to the footer of the search results page:

<?php
  $common_baseHREF = "http://www.www.domain.com";
  $common_path = "/home/domain.com/public_html/";
  $_GET["q"] = "[SEARCH_STRING]";
  require($common_path."searchExternal.php");
?>

where [SEARCH_STRING] is coming from the search query.  But:
1. php seems not possible to use in the search results footer
2. how can i use the [SEARCH_STRING] variable in this php-code?

Any help would be appreciated.  Thanks.
Logged
WebBird
Guest
« Reply #1 on: July 14, 2009, 12:04:24 PM »

Be careful on showing user input on an output page. This is a potential security issue.

The search string should be found in $_GET['string'];

Try
Code:
$_GET["q"] = $_GET['string'];
Logged
vanbemmel

Offline Offline

Posts: 22


« Reply #2 on: July 14, 2009, 12:55:40 PM »

OK, thanks but is it somehow possible to add php-code to that template?
Because every php-thing i tried is not displayed at all.
Logged
WebBird
Guest
« Reply #3 on: July 14, 2009, 01:04:14 PM »

Where did you add that code?
Logged
vanbemmel

Offline Offline

Posts: 22


« Reply #4 on: July 14, 2009, 01:31:12 PM »

In the footer of the search results page.

you can find it in the WebsiteBaker admin  ..../admin/settings/index.php?advanced=yes

In default there is only "</table>" there.
Logged
WebBird
Guest
« Reply #5 on: July 14, 2009, 02:54:04 PM »

I don't think you can add PHP Code there. I think you will have to add a conditional statement to your index.php. (Of the template you use.) I'm sorry but I don't have time to help at the moment.  embarassed Maybe tomorrow.
Logged
vanbemmel

Offline Offline

Posts: 22


« Reply #6 on: July 15, 2009, 03:44:53 PM »

Can you show an example how we could do that?

Maybe in template:

<if searchresultpage>show php code</if>  or something like that?
Logged
WebBird
Guest
« Reply #7 on: July 16, 2009, 09:58:18 AM »

I will try it out later and let you know. wink
Logged
Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4884



« Reply #8 on: July 16, 2009, 10:21:51 AM »

What about Droplets?

As far as I know Droplets are designed for such purposes as "Add php-code to search results footer"...

The [[Droplet]] itself can be inserted into the Footer-Loop.

Regards,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
WebBird
Guest
« Reply #9 on: July 16, 2009, 10:37:55 AM »

Yeah, great idea. I should have remembered. rolleyes I will try it out.
Logged
WebBird
Guest
« Reply #10 on: July 16, 2009, 10:48:53 AM »

Okay, try this:

Admin-Tools -> Droplets ->[Add Droplet]

Name: ExternalSearch
Description: <whatever you like>
Code:

Code:
$common_baseHREF = "http://www.www.domain.com";
$common_path = "/home/domain.com/public_html/";
$_GET["q"] = "[SEARCH_STRING]";
require($common_path."searchExternal.php");
return true;

Settings -> [Show advanced options >>] -> Search Settings -> Footer

Add: [[ExternalSearch]]

Important! I don't know what
Code:
require($common_path."searchExternal.php");
will do. If it creates output, you will have to "catch" this output and return it using return.

Code:
$common_baseHREF = "http://www.www.domain.com";
$common_path = "/home/domain.com/public_html/";
$_GET["q"] = "[SEARCH_STRING]";
ob_start();
require($common_path."searchExternal.php");
$return = ob_get_clean();
return $return;
Logged
vanbemmel

Offline Offline

Posts: 22


« Reply #11 on: July 16, 2009, 10:52:22 AM »

OK, but i use WB27 and that one doesn't have droplets right?
Logged
WebBird
Guest
« Reply #12 on: July 16, 2009, 11:07:01 AM »

No problem, you can install the droplets module in 2.7 as well. They work fine there, too.

http://www.websitebakers.com/pages/droplets/about-droplets.php
http://www.websitebakers.com/pages/admin/admin-tools/droplets.php
Logged
WebBird
Guest
« Reply #13 on: July 17, 2009, 12:56:45 PM »

I'd like to hear if it works?
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!