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}

eZ debug

Timing: Jan 18 2025 18:23:14
Script start
Timing: Jan 18 2025 18:23:14
Module start 'content'
Timing: Jan 18 2025 18:23:15
Module end 'content'
Timing: Jan 18 2025 18:23:15
Script end

Main resources:

Total runtime0.9142 sec
Peak memory usage4,096.0000 KB
Database Queries219

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 587.7344180.8281
Module start 'content' 0.00620.7779 768.5625712.6797
Module end 'content' 0.78410.1300 1,481.2422344.4297
Script end 0.9141  1,825.6719 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.4373210.0002
Check MTime0.00150.1667210.0001
Mysql Total
Database connection0.00090.095210.0009
Mysqli_queries0.821489.84482190.0038
Looping result0.00260.28012170.0000
Template Total0.878796.120.4393
Template load0.00220.237720.0011
Template processing0.876595.873920.4382
Template load and register function0.00020.017710.0002
states
state_id_array0.00160.173410.0016
state_identifier_array0.00100.105420.0005
Override
Cache load0.00200.2148630.0000
Sytem overhead
Fetch class attribute can translate value0.00140.156050.0003
Fetch class attribute name0.00090.0989130.0001
XML
Image XML parsing0.00190.204750.0004
class_abstraction
Instantiating content class attribute0.00000.0029150.0000
General
dbfile0.00330.3562400.0001
String conversion0.00000.003830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
10content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
19content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 46
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs