Forums / Developer / to put template name urls in javascript file in ezpublish

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.