2

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 delete 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

7
  • Why are you parsing minified 3rd party Javascript files anyway? Just for the heck of it? Commented Apr 27, 2011 at 22:38
  • I dont want that. It just happens as nothing is working ? I dont know why this is happening. Commented Apr 27, 2011 at 23:01
  • I don't have any experience with Smarty at all, are you sure you're using it correctly? Commented Apr 27, 2011 at 23:06
  • to be honest with you I dont know as I have never really cared about smarty. Somehow it is working fine on my Linux server but not on my windows pc. Thats insane. I checked the file permissions, I took care about the paths as I am using "DIRECTORY_SEPERATOR" and not / or \ and its just driving me nuts here... Commented Apr 27, 2011 at 23:33
  • You should take your script and style includes out of the {literal}. Commented Apr 27, 2011 at 23:59

2 Answers 2

1

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}&amp;enablejsapi=1&amp;playerapiid=ytplayer&amp;hl=en&amp;fs=1&amp;rel=0&amp;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

  1. you have syntax error in your PHP file ... validate your php
  2. your not giving smarty the correct location of some or all of your template files

    $smarty->display('index.tpl'); // will display a tpl file 
    
Sign up to request clarification or add additional context in comments.

7 Comments

Thank you for your answer @mcgrailm - Have a look at my inital post there is a link to my folder structure. That you can see on the left hand side in my IDE. layout.phtml 'code'{include file=$header} {include file=$bodyCnt} {include file=$footer}'code' This is the source code from the browser when I open my "index": pastebin.com/95WejcYL If you look at the bottom after line 300 you will see how I include my js files. However, It loads the file. I read it quite often that the path is relative to my php compile path from smarty. But it does not seem like that as I can open those.
i tried to load the js files without smarty at the end and at the beginning of my index.php file which is loading my framework. but those solutions did not work as well... I was always deleting the complied files and loaded my website with the "shift" + reload to load all resources again. Nothing changed...very very weird
I just saw it after your wrote the comment ;) But its still not working. I was adjusting it as I cannot {include file=$bodyCnt"} I modified it to {$bodyCnt} as I would otherwise get an error. However, it does not change anything. Edit: I obiviously did that with the header and footer file as well!
The errorconsole shows: Uncaught SyntaxError: Invalid regular expression: missing / As I have {literal} in the beginngin of my script.js file and at the end {/literal}. I somehow need this, the reason for that is, that I otherwise get a blank page but can see the source code.
@Richard I edited my post. you should never put smarty code in a js file if you need a smarty variable in your js it may be best to put that bit of js in the phtml.
|
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.