[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}

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 03:24:23
Script start
Timing: Jan 31 2025 03:24:23
Module start 'layout'
Timing: Jan 31 2025 03:24:23
Module start 'content'
Timing: Jan 31 2025 03:24:23
Module end 'content'
Timing: Jan 31 2025 03:24:23
Script end

Main resources:

Total runtime0.0459 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0045 588.1406151.2109
Module start 'layout' 0.00450.0040 739.3516220.7031
Module start 'content' 0.00850.0358 960.05471,009.9297
Module end 'content' 0.04420.0016 1,969.984441.9922
Script end 0.0458  2,011.9766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00275.9807140.0002
Check MTime0.00112.4772140.0001
Mysql Total
Database connection0.00061.315310.0006
Mysqli_queries0.00275.843530.0009
Looping result0.00000.071710.0000
Template Total0.00112.410.0011
Template load0.00081.807610.0008
Template processing0.00030.568810.0003
Override
Cache load0.00051.198910.0005
General
dbfile0.015132.870680.0019
String conversion0.00000.013040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs