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.

eZ debug

Timing: Jan 30 2025 21:18:50
Script start
Timing: Jan 30 2025 21:18:50
Module start 'content'
Timing: Jan 30 2025 21:18:50
Module end 'content'
Timing: Jan 30 2025 21:18:50
Script end

Main resources:

Total runtime0.2976 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0081 588.1875370.2578
Module start 'content' 0.00810.0130 958.44531,010.3594
Module end 'content' 0.02110.2764 1,968.80473,897.8359
Script end 0.2975  5,866.6406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00421.4026200.0002
Check MTime0.00130.4395200.0001
Mysql Total
Database connection0.00060.203310.0006
Mysqli_queries0.201667.73581410.0014
Looping result0.00140.47951390.0000
Template Total0.276092.810.2760
Template load0.00080.257810.0008
Template processing0.275392.504110.2753
Override
Cache load0.00050.176810.0005
Sytem overhead
Fetch class attribute can translate value0.00170.554810.0017
XML
Image XML parsing0.00030.086110.0003
General
dbfile0.01003.3634200.0005
String conversion0.00000.002430.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs