to put template name urls in javascript file in ezpublish

Author Message

Romeo Antony

Friday 11 June 2010 6:18:40 am

I have a line javascript code like this in one of the javascript filein javascript folder of my design directory

var url="i want to put pagalayout.tpl url here"

this is to apply some javascript to pagalayout.tpl file .

Do you have idea about how to add url of pagelayout.tpl that in the temaplets dir to javascript variable url.?

Thanks in advance

Romeo

H-Works Agency

Friday 11 June 2010 6:27:16 am

Hello,

Sorry but i don't understand what you wanna do.

What is the big picture ?

EZP is Great

H-Works Agency

Friday 11 June 2010 7:08:15 am

Ok but what do you mean by "url of pagelayout.tpl" ?

Pagelayout has no url, it is parsed in all urls of your siteaccess.

You mean you want to put the content of pagelayout.tpl in a javascript var ?

EZP is Great

Romeo Antony

Friday 11 June 2010 9:47:32 am

Martin, I am thankfull for u to help me .

I will explain the scenario.

I have created ezflow dynamic blocks and applied overflow . I run cronejob .it is working.But to see the automatic changes (overflow of contents in blcoks without refresh F5,) want to apply some ajax with javascript.hope u understand this.

Now i will tell u that javascript I used. U do not mind the whole code.I will bold the code the you need to look at.

I hav two files monitor.php and monitor.js

<span class="line">this is monitor.js
</span>

// JavaScript Document

var xmlHttp_monitor

function monitor()
{
xmlHttp_monitor = GetXmlHttpObject_parcel()
if(xmlHttp_monitor == null)
{
alert("browser does not support HTTP Request")
return
}
var url="monitor.php" ///I will apply the ajax with javascript refresh in this monitor.php by specify file name

xmlHttp_monitor.onreadystatechange = stateChanged
xmlHttp_monitor.open("GET",url,true)
xmlHttp_monitor.send(null)

}

function stateChanged()
{
if(xmlHttp_monitor.readyState==4 || xmlHttp_monitor.readyState == "complete")
{
document.getElementById("monitor").innerHTML = xmlHttp_monitor.responseText
setTimeout('monitor()',100);
}
}

function GetXmlHttpObject_parcel()
{
var xmlHttp_monitor=null;
try
{
xmlHttp_monitor=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp_monitor=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp_monitor=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp_monitor;
}

monitor.php file is like this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script src="monitor.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body onload="monitor();"> <div id="monitor"> <?php
$timezone = new DateTimeZone( "Europe/London" );
$date = new DateTime();
$date->setTimezone( $timezone );
echo $date->format( 'H:i:s A / D, M jS, Y' );
?> </div>
</body>
</html>

What I am trying to do is i am trying to apply the above javascript in my pagelayout.tpl for automatic refesh.

I have put the javscript in pagelayout directly by {ldelim}{rdelim}

But in javascript file i want to put the file name like u see var url="pagelayout.tpl"

it is not working.

But I think this is in only case of EZ.When I do the same codes in php and ASP it is working.

So any idea about how to put template path or filename, url in javascript.Any help would be appreciable.otherwise I want to try on diffrent javascript code.

Thanks in advance.

H-Works Agency

Saturday 12 June 2010 3:25:02 am

According to what i understand i can tell you this :

- Maybe you could use jquery or prototype setTimeout() directly in a javascript file after a "dom loaded" event, that could save you a lot of code.

- Notice that in ezpublish, JS and CSS loading come from design.ini files which are inserted in page_head.tpl which is inserted in pagelayout.tpl

- You can put a tpl url by allowing ".tpl" in your .htaccess then put the direct uri like : "http://domain/design/site/template/pagelayout.tpl" OR {concat('http://', ezsys('hostname'), 'pagelayout.tpl'|ezdesign)} (didn't try but it should work)

- Remember that when you want to espace "{}" in ezpublish template files - for exemple when using javascript - you can use :

"

<script>

var domain = {ezsys('hostname')};

{literal}

var obj = {'name':steeve, 'age':30};

alert(domain + obj.name);

{literal}

</script>

"

I hope it will help

EZP is Great

Romeo Antony

Sunday 13 June 2010 6:51:30 am

Martin, I am so thankfull for your reply.I was really struggling around this.I think I am closer to what I am looking.Can you help me in 3 steps too 1. How do need to put the .tpl extension in .htaccess_root as you told me.Where do I put it in below code order allow,deny allow from all 2.How do i put the path of pagelayout.tpl in javascript variable My pagelayout.tpl is in folder ( ezpublish\extension\ezflow\design\mydesign\templates) Do I put it like (http://127.0.0.1/ezpublish/extension/ezflow/design/mydesign/templates/pagelayout.tpl) I am trying to refresh the pagelayout.tpl completely after a certain timeout to show the overflow in dynamic blocks. Please give me suggestion Martin so I can go ahead. Sincere thank Romeo.

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 01:27:56
Script start
Timing: Jan 31 2025 01:27:56
Module start 'layout'
Timing: Jan 31 2025 01:27:56
Module start 'content'
Timing: Jan 31 2025 01:27:57
Module end 'content'
Timing: Jan 31 2025 01:27:57
Script end

Main resources:

Total runtime1.0152 sec
Peak memory usage8,192.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 589.5234151.2422
Module start 'layout' 0.00500.0046 740.7656220.7500
Module start 'content' 0.00961.0048 961.51564,504.7344
Module end 'content' 1.01440.0007 5,466.250019.7813
Script end 1.0151  5,486.0313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3372160.0002
Check MTime0.00120.1208160.0001
Mysql Total
Database connection0.00060.059010.0006
Mysqli_queries0.894388.0968660.0136
Looping result0.00070.0666640.0000
Template Total0.959794.520.4798
Template load0.00190.186920.0009
Template processing0.957894.346120.4789
Template load and register function0.00140.134810.0014
states
state_id_array0.00320.313410.0032
state_identifier_array0.00200.192120.0010
Override
Cache load0.00180.18031200.0000
Sytem overhead
Fetch class attribute can translate value0.00160.154420.0008
Fetch class attribute name0.00270.270080.0003
XML
Image XML parsing0.00330.329820.0017
class_abstraction
Instantiating content class attribute0.00000.0034120.0000
General
dbfile0.00560.5544230.0002
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 35
 Number of unique templates used: 10

Time used to render debug report: 0.0001 secs