History always repeats itself and sometimes that's good. Here's a second chance to be part of it: tmdtc.com
Showing posts with label ez publish. Show all posts
Showing posts with label ez publish. Show all posts

Thursday, 6 March 2008

Random image in Ez Publish

I'm working further with Ez, and it's an impressive tool. There's a lot to learn and discover, but it is a really powerful system. Here's how you can have a randomly chosen image displayed in your page:

{def $nodes=fetch( 'content', 'tree',hash( 'parent_node_id', 68 ,'class_filter_type','include', 'class_filter_array', array('image')))}
{def $number_of_images = count($nodes)}
{def $to_display = rand(0,$number_of_images|dec)}
{def $image = $nodes[$to_display]}
{attribute_view_gui attribute=$image.data_map.image}

Some lines and assignments might be superfluous, but were helpful when learning how to put that together. With this code in your template, one of the images stored as a child of the node with id 68 will be displayed.

One gotcha is that arithmetic operations don't work in the .tpl files, hence the use on |dec to decrement the variable $number_of_images.

Also, be sure to put this outside of all cache-block, or your image will be chosen once and for all the first time the template is compiled as it would be cached from then on!

And notice the call to attribute_view_gui to render the image.

You can do this with any other type of nodes, for example for the latest news, or customer quotes. I already see a use for the future Profoss website :-)

Wednesday, 5 March 2008

webdav in Ez publish on postgresql

So you're running Ez Publish 4.0 backed by a Postgresql database, and you want to use the webdav functionality. You followed the howto, but to no avail. Your webdav client does not have access (I had the message "folder or file does not exist" with Konqueror).
Here's a good advice: enable PHP logging, and take a close look to it. I found this error message for every webdav request sent:

PHP Fatal error: Call to undefined function mysql_real_escape_string() in /var/www/ezpublish-4.0.0/lib/ezdb/classes/ezmysqldb.php on line 908



The solution is simple, just install the php-mysql package.

I hope this saves you some time :-)