Forums / Developer / Take image path name from ezpblish design directory using javascript where we can\t use {literal}.

Take image path name from ezpblish design directory using javascript where we can\t use {literal}.

Author Message

Romeo Antony

Wednesday 23 June 2010 1:47:33 am

Hi all, anyone have an idea about how doing this.

I have a javascript file in javascript/design of ezpublish

in this javascript file, have a code like this

var id = this.id;
this.getElementsByTagName('IMG')[0].src = 'images/' + this.id + '_over.gif';

I want to get the path of an image file that is in the design dir of ezpublish

like /* this.id ._over.gif/ezdesign */

Gaetano Giunta

Wednesday 23 June 2010 3:12:57 am

what about calculating that path in a js block in the pagelayout and passing it to your js file via a javascript function invocation?

Principal Consultant International Business
Member of the Community Project Board

Romeo Antony

Wednesday 23 June 2010 4:21:42 am

Gaetano Giunta, thank you for your reply.

i was looking to include some javascript based css galleries that fetch content nodes from ezpublish and i would like to implement in ezflow as a block.

But what happends that most of the javscript code i get is retriving images from some image directory.

but as I am developing a dynamic contents i would not be able to put images each time in design dir of ez image

So how do I get the paath folder of images that are content nodes .

So I can put the path folder in javascript.

Gaetano Giunta

Wednesday 23 June 2010 5:01:13 am

Quite simple:

start with $node.data_map.image.content. This will give you an "ezimagealiashandler" object in your template

Look up the definition of ezimagealiashandler here: http://ez.no/doc/ez_publish/technical_manual/4_x/reference/objects/ezimagealiashandler

you will end up with something like this to get the path to the image file:

$node.data_map.image.content.variation.url

(where variation is the name of the image variant you want to use, that you will have beforehand customized in an image.ini.append.php file)

Principal Consultant International Business
Member of the Community Project Board

Romeo Antony

Thursday 24 June 2010 1:45:58 am

I have read through those document but i am still confused

about how can i change the javascript meaning full to ez

this.getElementsByTagName('IMG')[0].src = 'images/' + this.id + '_over.gif';

here javascript object this.id give name of an image appended wiith _over.gif will be a valid image file

that is for example ( arrow + _over.gif ) means arrow_over.gif file that is in ez design.

how do i put it in ez

any idea

i think it is like {append(this.id,"_over.gif")|ezdesign}

Isn't it

Gaetano Giunta

Thursday 24 June 2010 2:09:43 am

It sounds like you are confusing 2 things:

- template code ( ezdesign )

- javascript code ( this.id )

The first is executed ON THE SERVER, the second ON THE BROWSER. And the order of execution is 1st server, 2nd browser.

This means that you cannot have javascript code that calls template functions.

But you can have javascript code that is generated by template, and that will later execute.

The question is what are you exactly trying to do here: retrieve url of an image stored in the design folder or retrieve the url of an image stored in the contents? How do you plan to generate and store the "imagexxx_over.gif" image? Please answer clearly and we might try to come up with a simple answer

Principal Consultant International Business
Member of the Community Project Board

Romeo Antony

Thursday 24 June 2010 6:08:44 am

thank you Gaetano Giunta for u r reply.

actually I am struggling with creation of image gallery.I can tell you my idea so you may be able to get me.

using ezflow package

1. Created a dynamic block with its source node is image gallery contain images.

2. Now i am looking for to create the template file for this dynamic block

in this template want to display 6 thumbnails at the bottom and when click on thumbnail Need to enlarge the thumbnail clicked.

3. I can get the images from dynamic block in the template using

<img src={$valid_nodes[ ].object.data_map.image.content[original].full_path} width="" height=" ">(need img element so using full_path ).I can dispaly 6 thummbnails using above template code.

4. next what I am looking is need to apply scrolling to 6 image thumnails that took from dynamic block and to enlarge them when click on each thumnail.

5. For that I found many javascript supported by jqueries from net.you also told me that jquery is supported by ezjcore.

Any you give me further idea and example urls, any link , suggestions plz.

Thanks in advance Romeo.

Gaetano Giunta

Thursday 24 June 2010 8:00:53 am

Hey, you're 95% there!

What you are looking for is, if I got it right, the url of 2 different variations of your image. You can generate them using eg.

1. {$valid_nodes[ ].object.data_map.image.content[thumbnail].full_path}

and

2. {$valid_nodes[ ].object.data_map.image.content[original].full_path}

You should define the "thumbnail" size of images in an image.ini.append.php file.

You should then use the first url above to display the image directly in html, and pass the 2nd url to your js function that will load the "full size" version.

I am no javascript expert, but surely you will have to alter the js code you posted above:

from

this.getElementsByTagName('IMG')[0].src = 'images/' + this.id + '_over.gif';

to something like this:

function changeimage( newurl ) { this.getElementsByTagName('IMG')[0].src = newurl; )

where newurl is generated in the html by the template call above

Principal Consultant International Business
Member of the Community Project Board

Romeo Antony

Thursday 24 June 2010 3:45:36 pm

Thank you for your clear cut instructions Gaetano.

I think I am on the way to the target. As you said I have gone through the ezjscore article.

But somethings still confusing me about ezjscore.I am prefering jquery than yui3 library and like to load it from CDN

In the ezjscore.ini I put

LoadFromCDN=enabled

#PreferredLibrary=yui3 (means yui3 not selected)

PreferredLibrary=jquery

ExternalScripts[jquery]=http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js

in the template file for image gallery I put

{ezscript_require( array( 'ezjsc::jquery' ) )} (or do I need this {ezscript_require( array( 'ezjsc::jquery', 'ezjsc::jqueryio' ) )} )

I do not understand why (jqueryio item, which provides a wrapper for the ezjscore server call router.) this jqueryio needed

{ezscript_require( array( 'ezjsc::jquery' ) )} this would work isn't it

Then I look to add the jquery supporting javascripts for slide show of images.

Any suggestions will be helpfull for me to go ahead

eZ debug

Timing: Jan 18 2025 04:22:52
Script start
Timing: Jan 18 2025 04:22:52
Module start 'content'
Timing: Jan 18 2025 04:22:53
Module end 'content'
Timing: Jan 18 2025 04:22:53
Script end

Main resources:

Total runtime1.1990 sec
Peak memory usage4,096.0000 KB
Database Queries213

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.3281180.7656
Module start 'content' 0.00641.0609 769.0938632.1641
Module end 'content' 1.06730.1316 1,401.2578348.9766
Script end 1.1989  1,750.2344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.3479210.0002
Check MTime0.00160.1323210.0001
Mysql Total
Database connection0.00100.082210.0010
Mysqli_queries1.086090.58292130.0051
Looping result0.00220.18202110.0000
Template Total1.134394.620.5671
Template load0.00190.159420.0010
Template processing1.132394.443020.5662
Template load and register function0.00010.009610.0001
states
state_id_array0.00120.098510.0012
state_identifier_array0.03552.958420.0177
Override
Cache load0.00180.1521980.0000
Sytem overhead
Fetch class attribute can translate value0.00160.134530.0005
Fetch class attribute name0.00180.1487110.0002
XML
Image XML parsing0.00110.095730.0004
class_abstraction
Instantiating content class attribute0.00000.0041180.0000
General
dbfile0.00260.2151330.0001
String conversion0.00000.000430.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
9content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs