Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty interfering with JavaScript
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
bamajr
Smarty Rookie


Joined: 22 Feb 2008
Posts: 10
Location: Woodbury, MN

PostPosted: Thu Mar 08, 2012 5:41 pm    Post subject: Reply with quote

mohrt wrote:
bamajr wrote:
What happened to the days when the index.php file directed Smarty on what to load and when?


The index.php file has nothing to do with Smarty, you must be referring to something that was setup by your PHP developer at that time. (or something in a 3rd party application that uses Smarty.)


I was the PHP developer at the time, and I did create the index.php file so the Smarty .tpl files didn't have to have all the includes, to associate the header/footer with the index.tpl file.

mohrt wrote:
Smarty 2 has always had the issue with {} and literal tags. However as we have stated, Smarty 3 does have a new feature to help alleviate the problem. So long as {} tags are surrounded by white space, Smarty will ignore them.


I understand now, that this has been the case. I know that the index.php file I created was configured differently than the default Smarty would have originally included/suggested.

What I'm trying to figure out is if, the index.php file I configured, will cause all the Smarty functionality to be ignored.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Mar 08, 2012 5:44 pm    Post subject: Reply with quote

There is no "standard" Smarty index.php file. Your index.php file contains whatever you put in there. If you call $smarty->display() four times to load four different template pages in a row, that is up to you. Smarty does not care what you name your php files, or where you call Smarty. Smarty is just a PHP object that spits out content when you call $smarty->display(), wherever and whenever you decide to do that in your code.

So circling back to your original problem. You added javascript to the footer.tpl that had {} in the source, and errors began happening, yes? So either put spaces around the {} tags (Smarty 3), or use {literal} tags around the code containing {} tags.
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Mar 08, 2012 5:47 pm    Post subject: Reply with quote

bamajr wrote:
What I'm trying to figure out is if, the index.php file I configured, will cause all the Smarty functionality to be ignored.


Your index.php file calls $smarty->display() four times in a row, each loading a different template. So long as the templates are valid Smarty syntax, they should echo the content.
Back to top
View user's profile Send private message Visit poster's website
douglassdavis
Smarty Junkie


Joined: 21 Jan 2008
Posts: 541

PostPosted: Thu Mar 08, 2012 5:56 pm    Post subject: Reply with quote

Just an observation, but I don't see where the templates you posted have any smarty functionality at all.
Back to top
View user's profile Send private message
bamajr
Smarty Rookie


Joined: 22 Feb 2008
Posts: 10
Location: Woodbury, MN

PostPosted: Sat Mar 10, 2012 9:53 pm    Post subject: Reply with quote

douglassdavis wrote:
Just an observation, but I don't see where the templates you posted have any smarty functionality at all.


For the most part, I would say you are absolutely correct. I'm using template caching only for the example(s) I gave.
Back to top
View user's profile Send private message
bamajr
Smarty Rookie


Joined: 22 Feb 2008
Posts: 10
Location: Woodbury, MN

PostPosted: Sat Mar 10, 2012 10:05 pm    Post subject: Reply with quote

mohrt wrote:
bamajr wrote:
What I'm trying to figure out is if, the index.php file I configured, will cause all the Smarty functionality to be ignored.


Your index.php file calls $smarty->display() four times in a row, each loading a different template. So long as the templates are valid Smarty syntax, they should echo the content.


The do "echo the content" as they should.

This is where I'm getting a little confused about how Smarty 3 works.

I provided an example of an index.php file, which calls $smarty->display() four times in a row, to render http://annesconsulting.bamajr.com/, from four .tpl files, using Smarty 2.

When I use this same method for my new page (the one with the JavaScript in it), I do not have to add the {literal} or {rdelim}/{ldelim} tags for the page to load correctly, JavaScript and all.

However, if in my index.php file, I use $smarty->display() to call only index.tpl, and then call header.tpl and footer.tpl in my index.tpl file, I have to add the {literal} or {rdelim}/{ldelim} tags for the page to work.

I don't understand why this is the case.

Does this make the issue more clear?

OFF TOPIC: At the very bottom of the smarty.net page, there is a line that says: "This page generated in 0.01472 secs with ..." Where is this data coming from? Is this a plugin or lib file which is part of Smarty 3?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Mar 10, 2012 10:37 pm    Post subject: Reply with quote

we must see the corresponding template files for the two cases...
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sun Mar 11, 2012 9:22 pm    Post subject: Reply with quote

Quote:
However, if in my index.php file, I use $smarty->display() to call only index.tpl, and then call header.tpl and footer.tpl in my index.tpl file, I have to add the {literal} or {rdelim}/{ldelim} tags for the page to work.


It should not matter, post your template source and post the exact error.

Code:
OFF TOPIC: At the very bottom of the smarty.net page, there is a line that says: "This page generated in 0.01472 secs with ..." Where is this data coming from? Is this a plugin or lib file which is part of Smarty 3?


That is just something I wrote to time the pages. You will want to time more than just Smarty to get an accurate page timing. It is as simple as:

Code:
$time1 = microtime(true);
// do everything.
$time2 = microtime(true);

// now total page time is $time2-$time1
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP