Jump to content

[SOLVED] Calling Part of PHP Script (Again)


zoomology

Recommended Posts

Hello,

 

I'm hoping someone can help resolve my problem, or at least tell me whether it's possible or not so I can elect another option.

 

GOAL

I want to call a particular function of a PHP script, a queried term, and print it to the <title> and/or <h1> tag of a document on the fly for a given search.

 

THE SCRIPT

The script in question is the Zoom search engine (PHP install). The script is called and the search results are created by virtue of an include <?php include("search.php"); ?> which is inserted into my website's .php template file.

 

PROBLEM

Unlike most off-the-shelf site search scripts, Zoom doesn't generate page titles at top of the page for a particular query. Further, all requests (so far) to Zoom's support staff have been ignored.

 

ESTABLISHED

I have been successful inserting the query term using <?php print "$query"; ?> however, it will only work when placed below the point of where the script include is added to the template, seemingly since the script's code is called (and search results generated) between the template's header and footer.

 

SUMMARY

It may be possible to use <?php print "$query"; ?> to generate the searched term in various other areas on the page, however I don't have the requisite skills to code the template to facilitate the task. I theorize that it may possible to do this using code I'm unfamiliar with -- such as a type of "include() once" placed at top of the template's code.

 

Could a language construct such as echo(), print(), include(), or require() be added to beginning of the template file to call the $query so as to print to placeholders within the page titles and heading tags?

 

<?php

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?php print("$query"); ?></title>

<h1><?php print("$query"); ?></h1>

 

HOST SERVER

Apache/1.3.37

PHP/4.3.10

 

 

...any help appreciated. Thanks.

 

.

Link to comment
Share on other sites

In case anyone's interested in acheiving the same results, here's the fix.

 

The following was added to the .htaccess file. Note that mywebsite.net is changed to my own domain and support.php is my template filename. Adding the mod_rewrite rules allow me to link to a specific keyword search that uses a more search engine friendly URL. The + sign was left in place so as not to interfere with Zoom's other algorithms.

 

example: <a href="/asbestos+dust.php">asbestos dust</a>

 

<FilesMatch "\.(php|html?)$"> 
   php_value zlib.output_compression 4096 
</FilesMatch> 

<Files /> 
   ForceType application/x-httpd-php 
</Files> 

php_flag allow_url_fopen on 
php_value allow_call_time_pass_reference 1 

Options +FollowSymLinks 
ErrorDocument 404 http://www.mywebsite.net 

RewriteEngine On 

RewriteCond %{HTTP_HOST} !^www\.mywebsite\.net [NC] 
RewriteRule ^(.*)$ http://www.mywebsite.net/$1 [R=301,L] 

RewriteCond %{SCRIPT_FILENAME} !-f 
RewriteRule ^([^/]+)\.php$ /support.php?zoom_query=$1 [L]

 

 

The below was added inside the <title> and <h1> tags to generate the searched term in those areas of my template.

 

<title><?php echo htmlentities($_GET['zoom_query'], ENT_QUOTES); ?></title>

<h1><?php echo htmlentities($_GET['zoom_query'], ENT_QUOTES); ?></h1>

 

In any event, everything's working okay now and I'm a happy camper.

 

.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.