Forums / Setup & design / Javascript inside EZPublish script

Javascript inside EZPublish script

Author Message

Iris Hoekstra - Roscam Abbing

Thursday 26 February 2004 5:56:08 am

(Sorry for cross-posting but I accidentally posted this in the EZP 2.2 forum before.)

I know I am the thousandth (sp?) person to ask a Javascript question but I have searched all over the site and I just can't figure this one out.

I have a Javascript which returns an integer. This is working well. Now I want to pass the number as an argument to a fetch command, like this:

{let remarks=fetch( 'content', 'list', hash(parent_node_id, $module_result.node_id,
offset, [NUMBER CALCULATED BY JAVASCRIPT NEEDS TO GO HERE],
class_filter_type, 'include', class_filter_array, array(14)))}

Is this possible?

Paul Forsyth

Thursday 26 February 2004 6:52:48 am

Im not sure this is possible because of the order of processing that occurs.

A template will be processed by the php, and html produced for the browser to read, and it is at this point the Javascript functions are executed. So it appears there is no way to get template function to read your value.

How does this number get calculated, as it appears the js must know something about the node structure....?

paul

Iris Hoekstra - Roscam Abbing

Thursday 26 February 2004 7:53:06 am

Maybe I'm on the wrong track here.

All I want to do is a 'quote of the day' type of thing. I have got a number of objects of the class Remark. I want to show a different one every time the page loads. After you said I couldn't use JavaScript inside EZP script I found this: http://www.ez.no/content/download/44166/112705/file/shuffle.zip. I unpacked it in c:\eZpublish and followed the instructions for modifying my site.ini file.

But it doesn't seem to be doing anything... :-(

Paul Forsyth

Thursday 26 February 2004 8:40:19 am

Can you say more about what you want to do? Its not too clear to me.

You can't use javascript *within* ez script in a normal template. but you can use ez script within javascript, because of the order of processing.

paul

Iris Hoekstra - Roscam Abbing

Thursday 26 February 2004 8:51:04 am

Sorry, I wasn't very clear. I meant that I have made a class called Remark. Basically an object of this class is little more than a line of text.

I have made various 'Remark' objects but I only want to show one at a time on the webpage and I want it to be picked at random whenever a user hits the page. So at first, I was trying to generate a random number with Javascript and pass that as the offset parameter to the fetch function. Then I tried to use the 'shuffle' extension mentioned above. But none of that works.

I hope this explains what I'm trying to do.

Paul Forsyth

Thursday 26 February 2004 11:40:34 am

Well, regarding your entry on the shuffle contribution the ez root directory is the directory containing directories like kernel, lib, design, etc. The import directory is extension and you must place the shuffle extension into it.

ashok ashok

Monday 19 April 2004 7:11:09 am

Hello friends,
I want to display sub menus on drop down fashion instead of clicking and showing it on the left hand side. We want to display sub menu whenuser takes his mouse point on the top main menu.
Any suggestion / idea how do i achieve my target.
Regards,
Ashok Naidu

Jorge estévez

Thursday 13 December 2007 7:34:12 pm

Hello!

I have a similar issue.

I am making a site with 250 000 items.

Regarding usability needs users can select how many items the want to display in a page so each time the user changes the value I save a cookie, and each time simmilar pages are loaded load the cookie value again...

The value must be added to the fetch code to fetch the number of items the user needs to display in his page...

Maybe cache pages at some point should be turned of (really do not know where), but the FETCH NEED to have the javascript value so it fetches the right number of items…
Any clues?

I just cannot believe Ez could not handle this somehow

Best regards,

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Jorge estévez

Thursday 13 December 2007 7:48:14 pm

Second thoughts...

Ok, now processes and their order surely have to do with this issue as fetch “runs” first and then JavaScript will run once the page has been rendered…

Any workaround?

This limits ez from doing any kind of combinations between JavaScript and its own script language…

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

André R.

Friday 14 December 2007 8:01:25 am

This post is on the wrong track, this is not a lost feature in the "eZ scripting" language.
eZ templates (aka 'eZ Scripting') is done on the server, like php, asp, asp.net scripts.

You can not mix javascript ( witch runs on the client side ) directly with server side scripts since they run at two different machines.

You can make the server and client code interact together by storing data in cookie (not directly supported in template language, but you can create custom template operators to handle this, search in contributions) put variables in the URL (use view parameters witch is naively supported by eZ Publish), or sending xmlHttpRequest (Ajax) to interact with the server without refreshing the page.

EDIT: more info here:
http://www.hscripts.com/tutorials/javascript/

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom