Forums / Developer / [solved] original_filename attribute

[solved] original_filename attribute

Author Message

Steve Brown

Sunday 10 July 2005 3:00:18 pm

I've spent half a day guessing -- could someone kindly tell me the correct syntax for extracting the "original file name" attribute of an image (which is an attribute of a custom product class I've created).

I would expect something like:

<b>$node.object.data_map.image.original_filename</b>

or

<b>$node.object.data_map.image['original_filename']</b>

to work, and I've tried dozens of other possibilites. I believe that I can use the original file name in conjunction with the ezimage template function to allow a user to download the original file, assuming it is located in the correct image directory.

Any assistance is greatly appreciated.

Eivind Marienborg

Sunday 10 July 2005 11:09:51 pm

{$node|attribute(show)}

This will show you -all- attributes of your node. You'll find the original_filename-attribute there.

Bruce Morrison

Monday 11 July 2005 12:34:30 am

Howdy

No need for guessing!

Check out the the excellent new documenation. These pages should help if Eivind's advice doesn't help you (which it will).

http://ez.no/doc/ez_publish/technical_manual/3_6/reference/datatypes/image
http://ez.no/doc/ez_publish/technical_manual/3_6/reference/objects/ezimagealiashandler

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Paul Borgermans

Monday 11 July 2005 2:10:57 am

Hi Steve

You are missing the content part

{$node.object.data_map.image.content.original_filename}

should do the trick

It's the same with binary file attributes

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Steve Brown

Monday 11 July 2005 10:07:34 am

Thanks to all who replied. With some additional research, I've been able to figure out that a "content object" won't work with {attribute_view_gui} (causes a fatal error) but with {content_view_gui}, it's not working as I'd expect but at least it doesn't produce an error message.

When I use:

<a href={content_view_gui content_object=$node.object.data_map.image.content.original_filename}>Download</a>

all I get is a label with a link to the current page. Without the <a></a>, I seem to be getting an empty string. I'll worry about the path once I figure out how to get the file name. What am I missing???

Bruce Morrison

Monday 11 July 2005 5:12:52 pm

Hi Steve

The content_view_gui template function is expecting a content object as the content_object parameter. See:
http://ez.no/doc/ez_publish/technical_manual/3_6/reference/template_functions/visualization/content_view_gui

Though I'm not sure this will achieve what you are trying to do. However...

<a href={$node.object.data_map.image.content.original_filename|ezurl}>Download</a>

...should achieve that you want.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Steve Brown

Monday 11 July 2005 7:25:50 pm

Bruce's suggested code gives me an error with the following debug output:

Warning: PHP  	Jul 11 2005 21:32:56

Undefined property:  DataTypeCustom in /var/www/html/mia/kernel/classes/datatypes/ezimage/ezimagealiashandler.php on line 443

Warning: PHP 	Jul 11 2005 21:32:56

Undefined variable:  imageRow in /var/www/html/mia/kernel/classes/datatypes/ezimage/ezimagealiashandler.php on line 1414

Is it possible that it's not working because the attribute, image.content.original_filename, is for a custom class (a product named my_image)? If so, how do I get it to work? If not, what else could be wrong?

Eivind Marienborg

Thursday 14 July 2005 10:03:08 pm

As long as your attribute is a default image attribute, and the attribute is named image, the above code should work.

But you aren't using any content_view_gui or anything, right? Cause accessing the original_filename will return a string (with the original filename), and not an ezobject/ezattribute (which is needed for the _view_gui functions to work).

Steve Brown

Saturday 16 July 2005 8:56:42 pm

Eivind,

If I used any _view_gui's, it was while I was trying anything and everything to figure out how to get a link to the original file of an image in my custom product. Did you see the debug output I posted? I went back and tried creating a single-attribute class - just an image - but it still didn't work. Maybe nobody else can reproduce this. I suppose I could try with a fresh install in another directory or another computer, if necessary.

Steve Brown

Friday 22 July 2005 10:50:22 am

If I assigned the object to a variable with {let}, it works:

{let attribute=$node.object.data_map.picture}

<a href={$attribute.content.original_filename|ezimage}>Download</a>
{/let}