Thinking about it, the bit of script that is writing $rpath
is likely causing problems.
Rather than using ../
to find your root, use includes like this:
include $_SERVER["DOCUMENT_ROOT"] . "/mypath/myscript.php";
Thinking about it, the bit of script that is writing $rpath
is likely causing problems.
Rather than using ../
to find your root, use includes like this:
include $_SERVER["DOCUMENT_ROOT"] . "/mypath/myscript.php";
you mean like this?
if ($dir == $_SERVER["DOCUMENT_ROOT"] . "/blend") {
include $_SERVER["DOCUMENT_ROOT"] . "/1cde/amznbl.php";
}
Possibly not this bit:
($dir == $_SERVER["DOCUMENT_ROOT"] . "/blend")
but certainly the second line.
Try throwing a very simple test into your directory and run it.
echo '<p>CWD: '.getcwd().'</p>';
echo '<p>Docroot: '.$_SERVER["DOCUMENT_ROOT"].'</p>';
Once you know what they both output, you know what you need to do to make them match up.
Eg;
$dir = str_replace('bits of path you dont want', '', getcwd() ) ;
Hi - the problem with this solution is that I must have multiple files “amzn*.php”. And if I make a small change in one file, I have to change them all!
I’m trying a different solution now with:
where I can put the search phrases for each folder in a functions.php and have just this on the main page:
<?php echo getPrase(); ?>will keep you posted…
Hi Val. That link take me to the profile of someone. Was it meant to link to a thread giving you an answer to your issue?
Hi no - that’s the guy I’m paying $35 for the solution. It’s really neat. It’s working great. Will ask his permission to post it here. He’s giving it to me by email not online.
Hi – here’s the solution. It works perfectly. Now I can change things like search phrase and amzn_assoc_title in one file, namely, functions.php, instead of having to change things individually in multiple files.
I was lucky, I was able to simply add it to my wordpress functions.php so I never had to add anything to the top of files. Almost all my pages are NOT wordpress, but they all call up the wp environment with:
<?php require '../wp-blog-header.php';?>
so I can use a wordpress testimonials plugin on non-wordpress pages.
So if you have wordpress functions.php, you just add the functions.php code below to it, and if you don’t have wordpress, then you create a functions.php in root.
From Andrew at http://www.phphelp.com/forum/index.php?action=profile;u=72272:
Install functions.php in the root directory (if you don’t have wordpress).
Add the following line to the top of the files where you will be using it:
<?php include $_SERVER['DOCUMENT_ROOT'] . '\functions.php'; ?>
//not needed if you’re using wordpress functions.php
In those same pages, where you currently have the amazon JavaScript code, remove it and add the following:
<?php echo getPhrase(); ?>
here’s the file for functions.php:
function getPhrase() {
$phrase = array (
'default' => 'sprouters',
'blend' => 'countertop blenders',
'dhd' => 'dehydrators',
'eat' => 'raw food',
'hydro' => 'hydroponic towers',
'juice' => 'auger juicers',
'sprout' => 'sprouters',
'water' => 'alkaline water ionpod',
);
$amazonTemplate = <<<TXT
<script type="text/javascript">
amzn_assoc_placement = "adunit0";
amzn_assoc_tracking_id = "gogreen047-20";
amzn_assoc_ad_mode = "search";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_textlinks = "";
amzn_assoc_linkid = "";
amzn_assoc_default_search_phrase = "{{phrase}}";
amzn_assoc_title = " >> Find Today's Top Bargains in Appliances & Raw Foods!";
</script>
TXT;
$uri = explode ( '/' , $_SERVER ['REQUEST_URI'] );
$interest = $uri [count ( $uri ) - 2];
$search = '';
if (array_key_exists ( $interest, $phrase )) {
$search = $phrase[$interest];
} else {
$search = $phrase['default'];
}
return str_replace('{{phrase}}', $search, $amazonTemplate);
}
cool, eh? To see it in action, go to http://greensmoothie.com/ and click on any of the dropdowns from “Eating Raw” on (ignore Free Stuff & Shop), scroll to bottom of a page and you’ll see in each folder (eat, sprout, blend, etc) it has a different search phrase and thereby displays amazon products that are unique to that folder (raw food, sprouters, blenders, etc).
thanks for everyone’s input! – Val
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.