Page 1 of 1
Need to add a php script
Posted: Thu Feb 17, 2011 10:04 am
by deludeddonny
Hello I have a php script which I need to add to the product page,
any ideas? php include does not work and crashes my website....
I think I will need to add it to catalog/model/catalog/product.php and then call it in the product.tpl file...
but I have no idea how to do that...
Re: Need to add a php script
Posted: Thu Feb 17, 2011 10:14 am
by Qphoria
You can include directly from the tpl file
<?php include ('path/to/file.php'); ?>
Re: Need to add a php script
Posted: Thu Feb 17, 2011 10:42 am
by deludeddonny
I tried that, but it bombed my site... Dunno why but it didn't like it
Re: Need to add a php script
Posted: Thu Feb 17, 2011 10:46 am
by Qphoria
well "bombed my site" means nothing.. maybe your script was garbage.
Re: Need to add a php script
Posted: Thu Feb 17, 2011 10:56 am
by deludeddonny
Script runs fine if you view it in it's own page... When using php included it doesn't load the page and after 5 minutes of trying to load it gave a random SQL error first time and second time gave a 500 error, I am using the vqmod to display SKU on product page, could they be conflicting or something!
Re: Need to add a php script
Posted: Thu Feb 17, 2011 3:32 pm
by Chones
Try putting the php code directly in the template file - I do that all the time.
Re: Need to add a php script
Posted: Thu Feb 17, 2011 7:51 pm
by deludeddonny
I did try that but it only reognises the first few lines as php.
I have asked the people who designed the script to have a go at inserting it.
If they cant get it right (god help us all LOL) then I am going to remove vqmod and try php include again, I am fairly sure they were conflicting somehow...

Re: Need to add a php script
Posted: Thu Feb 17, 2011 8:46 pm
by deludeddonny
ok they tried to do it,
still get 500 error, i removed vqmod but still not working... this is very strange

Re: Need to add a php script
Posted: Thu Feb 17, 2011 9:13 pm
by Xsecrets
well if their script runs on it's own it may be an issue of conflicting headers or something along those lines. Is the script designed to be embedded into other pages or to run on it's own?
Re: Need to add a php script
Posted: Thu Feb 17, 2011 9:27 pm
by deludeddonny
OK this is out my error log
2011-02-17 5:36:45 - PHP Warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/content/40/7355040/html/shop/catalog/model/catalog/timer.php on line 90
and this is line 90 of the file in question...
if (in_array($dayDate, $holidays)) {
return false;
Well its a custom bit of script I have had made, they knew it was supposed to be embedded,
they edited it so I can use
<?php
include('timer.php');
echo(getCountDownTimerString());
?>
it works if i put that in a blank php file but gives 500 error when i add it to product.tpl
Re: Need to add a php script
Posted: Thu Feb 17, 2011 10:23 pm
by Qphoria
There is no conflict that I can think of that would be caused by vQmod for this. vQmod makes its changes before the file is evaluated, so to vQmod, the include is just another string
Re: Need to add a php script
Posted: Thu Feb 17, 2011 10:26 pm
by Xsecrets
deludeddonny wrote:OK this is out my error log
2011-02-17 5:36:45 - PHP Warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /home/content/40/7355040/html/shop/catalog/model/catalog/timer.php on line 90
and this is line 90 of the file in question...
if (in_array($dayDate, $holidays)) {
return false;
Well its a custom bit of script I have had made, they knew it was supposed to be embedded,
they edited it so I can use
<?php
include('timer.php');
echo(getCountDownTimerString());
?>
it works if i put that in a blank php file but gives 500 error when i add it to product.tpl
well the most likely cause of that error is that the array is not set, which would mean backtracking through the program to figure out why not.
Re: Need to add a php script
Posted: Fri Feb 18, 2011 12:48 am
by deludeddonny
OK odd but I think this is causing it...
Code: Select all
function isDayOK($ts) {
global $holidays;
global $daysWorking;
$dayDate = date(DATE_FORMAT, $ts);
$dayOfTheWeek = date('N', $ts);
if (in_array($dayDate, $holidays)) {
return false;
}
if (!$daysWorking[$dayOfTheWeek]) {
return false;
}
return true;
}
Here is the array
Code: Select all
$holidays = array(
'01/01/2011',
'25/12/2011'
);
$daysWorking = array(
'1' => true,
'2' => true,
'3' => true,
'4' => true,
'5' => true,
'6' => false,
'7' => false,
);