smarty should not parse javascript file
through stackoverlfow and google I found many things for this and many complaints and basically everything. hence I must be totally stupid to achieve this but I want my smarty not to parse my javascript.
Somehow, it is doing that. As in the documentation stated: {literal}{/literal} escapes blocks from being parsed by js. However, that is working fine. For instance this template: http://pastebin.com/nfM1S1D8
Its working as it should... BUT
what ever is written in those things is totally parsed and ignored from top to bottom. I could write 100 times {literal} in that file and it would not give a rats ass about that. And its not just that. Also my jquery142min and my jqueryui1812min file are destroyed by this smarty thing. I cannot use any jquery stuff anymore:(((
Could somebody please tell me how I get smarty not to care about a whole file? I am not going to paste the jqueryUI file just to show that it looks like this: {literal} jquery ui code {/literal}
Believe me guys, I tried it with the
$smarty->left_delimiter = '<!--{';
$smarty->right_delimiter = '}-->';
But that does not work as well - and YES I did delete the cache that doesnt exsist as I am not caching and YES I did d开发者_如何学JAVAelete the compiled views every single time!
So you see I must be too stupid to solve this here but I hope somebody else has an answer for this.
PS: structure and smarty code: http://img560.imageshack.us/f/smarty.png/
@edit: "The js file will be called with reference to the PHP file that calls the template . The path will not be according to where the smart y template is but according to where the calling php file is."
Does not apply to me as I can open after the parsing the js files
I'm not sure what is going on for you but your doing wrong but i'll give you a few basics
you don't need
{literal}.... {/literal}
to include a file, example
<script type="text/javascript" src="{$prefix}js/jquery.form.2.64.js"></script>
DO NOT PUT LITERAL TAG IN LOADED JS FILES IE WILL CAUSE PROBLEMS WITH YOUR JAVASCRIPT
but if i wanted to include say swfobjec iw would do it like this
{literal}
<script type="text/javascript">
var params = { allowScriptAccess: "always", wmode: "transparent"};
var atts = { id: "myytplayer"};
swfobject.embedSWF("http://www.youtube.com/v/{/literal}{$youtube_id}{literal}&enablejsapi=1&playerapiid=ytplayer&hl=en&fs=1&rel=0&autoplay=0","ytapiplayer", "689", "400", "8", null, null, params, atts);
</script>
{/literal}
your not fetching the output of the files change your phtml assignments like this
$smarty->assign('bodyCnt',$smarty->fetch(APPLICATION_PATH . DS . "view" . DS .$controller . DS . $action . ".tpl"));
please note that I changed the file name to ".tpl" you should not have any php in your tpl files there should only be html and smarty in these files
if your getting a blank page there are a couple of things that could be going on
- you have syntax error in your PHP file ... validate your php
your not giving smarty the correct location of some or all of your template files
$smarty->display('index.tpl'); // will display a tpl file
I found the problem. I am very sorry for smarty. Smarty is working fine and I suppose that everything worked fine in the beginning.
The problem was/is my script.js file.
What did I do to find this out: 1st I created a backup of my script.js file. 2nd I made sure that the encoding of the file is utf-8 is. 3rd I created a formater in my Zend Studio to format the whole file after it was a bit messed up. 4th - So far it still didnt work. 5th - I deleted everything - It worked - but obviously no javascript as nothing was called. 6th - I added my document.ready function from jquery - did not work again 7th - I deleted the .ready and tried it with every single function. - After that I was sure it is about the .ready function 8th - I splitted my ready function and than found the following line that caused the problem: [code]google.load('search', '1', { language : 'en', style : google.loader.themes.MINIMALIST } );[/code]
I would like to thank @mcgrailm for his efforts. And lastly I hope that even though its just a matter of "debugging" the js file. I hope that somebody who encounters the same problem gets the little bit of idea to solve his/her own problem.
精彩评论