Member
Member
itough   2008-08-28, 10:59
#1
I am hoping to integrate some Zenphoto galleries and images into a MODx site, but am having some problems. If anyone has any ideas about what could be causing this I would be very grateful for any feedback. I will post this on the MODx and Zenphoto forums.

The following two bits of php code are intended to:
1. Allow the use of Zenphoto functions from a non-zenphoto site.
2. Display a random image from a Zenphoto album on the page.
They seem to work as expected if placed in a page that is not part of my MODx site.
If I place the code into snippets and place those snippets in my template I get the error message displayed below.

MODx and Zenphoto are both sharing the same MySQL database. The Zenphoto tables have a prefix of zp_ to keep them separate from the MODx ones. I did originally have a separate database for Zenphoto but had the same problem.

MODx is running from within the root of the site /. Zenphoto is in a folder called /zenphoto. I don't think there is a problem with the paths described as MODx appears to be reading the zenphoto 'template-functions.php' file OK. The correct user name and password are entered in the zenphoto config file. I thought that it might be a problem accessing the zenphoto config file so I added `require_once('zp-config.php');` but it did not help.

I am using Zenphoto 1.2 and MODx 0.9.6.1

I should mention that the display of a random image is not all I wish to achieve by integrating Zenphoto! It just seemed like a good starting point for experimentation.

Andy

`

<!-- gives access to the zen photo template functions -->

<?php

define('ZENFOLDER', 'zp-core');

define('WEBPATH', 'zenphoto');

require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

?>

<!-- displays a random image from a zen photo gallery -->

<?php

$randomImage = getRandomImages();

$randomImageURL = getURL($randomImage);

echo "

<img src='". $randomImage->getSizedImage(getOption('image_size')) . "'

alt=\"random image\"\n" . $randomImage->getTitle() . '" />';

?>

<!-- error displayed when run as a snippet from within MODx. (The real user name is displayed)-->

« MODx Parse Error »

MODx encountered the following error while attempting to parse the requested resource:

« PHP Parse Error »

PHP error debug

Error: mysql_connect() [function.mysql-connect]: Access denied for user: 'username@localhost' (Using password: NO)

Error type/ Nr.: Warning - 2

File: /home/itough/www/www/zenphoto/zp-core/functions-db.php

Line: 33

Line 33 source: $mysql_connection = @mysql_connect($_zp_conf_vars['mysql_host'], $_zp_conf_vars['mysql_user'], $_zp_conf_vars['mysql_pass']);

`
Administrator
Administrator
acrylian   2008-08-28, 13:52
#2
I only know MODx by name but the point might be that you run it as a snippet (I assume that is code posted in a section or so) .
Try to include the defines and the require_once of the template-functions directly on your MODx template file(s).
Member
Member
itough   2008-08-28, 14:15
#3
Thanks for the response. It looks like I have to use "MODx snippets" for php functionality to be invoked. Placing all the code directly into the template file results in the following output on the rendered page: `\"randomgetTitle() . '" />'; ?>`
Any further thoughts greatly appreciated! Andy
Member
Member
Andis   2008-08-28, 21:24
#4
Have you ever tried to run zenphoto as a plugin (not a snippet) with the OnWebPagePrerender event activated?
I never tried by now, but this is where i probably would start.
Good luck
Member
Member
itough   2008-08-28, 22:53
#5
The technical support guys from ICDSoft.com who host my domain have come up with a solution to this problem. Instead of placing the: [code]<?php
define('ZENFOLDER', 'zp-core');
define('WEBPATH', 'zenphoto');
require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");
?>[/code] as a snippet in a template it needs to be placed into the MODx index.php file.

The other code: [code]<?php
$randomImage = getRandomImages();
$randomImageURL = getURL($randomImage);
echo "
<img src='". $randomImage->getSizedImage(getOption('image_size')) . "'
alt=\"random image\"\n" . $randomImage->getTitle() . '" />';
?>[/code] is used as a snippet inside templates.

Thanks to acrylian for you earlier help with this. Andis, thanks for your suggestion. In light of the solution from ICDSoft I have not tried this.

Andy
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.