Escaping { in custom module code
So I figured out how to make a new module
(http://kb.x-cart.com/display/XDD/Creating+sidebar+menu+in+customer+area was a good guide). I am using my sidebar module to display some code from MailChimp - a newsletter signup. I would also like to use it to display my sharing icons from ShareThis.com. However, using { } doesn't work - gets ignored. What's the escape character or some workaround? HTML Code:
<script type="text/javascript">stLight.options({publisher: "redacted", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script> This may be a very newbie question but I haven't found the answer yet. Thanks in advance! |
Re: Escaping { in custom module code
Either use {literal} tag or replace { } with {ldelim} {rdelim}
Code:
{literal}<script type="text/javascript">stLight.options({publisher: "redacted", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script> Code:
<script type="text/javascript">stLight.options({ldelim}publisher: "redacted", doNotHash: false, doNotCopy: false, hashAddressBar: false{rdelim});</script> |
Re: Escaping { in custom module code
Oh, just like in X-Cart 4. I forget so soon! :-) Thanks, I'll give it a try.
|
Re: Escaping { in custom module code
Oh sorry this is for XC5. That won't work. What I said applies to smarty, you have to find the alternative for Flexy
|
Re: Escaping { in custom module code
Flexy should be ignoring {} inside of a <script> element. http://pear.php.net/manual/en/package.html.html-template-flexy.attribute.tojavascript.php
Your JS code looks odd to me. Where is the example of proper setup from ShareThis? |
Re: Escaping { in custom module code
You can see this straight from sharethis.com. You don't have to specify a site but you do need to log in.
HTML Code:
<script type="text/javascript">var switchTo5x=true;</script> Publisher value was "redacted" in earlier code post. Sharethis wants the code in the <head> actually. (I'll take advice on how to do that as well...) I have another module (MailChimp) that also needs {'s, not in the <head>. Things that haven't worked so far (assume the complementary closing tag): {literal} around script line { \{ {{ {{{ |
Re: Escaping { in custom module code
Hi haleystudio!
You are right, Flexy thinks that {publisher: } is a call of method getPublisher() and that is why omits everything after ':' character. You can work around this problem if you add method like getShareCode() into your PHP class. This method would return the needed JS code. Then, you should call {getShareCode()} in your template and the JS code will be properly added there. Tony. |
Re: Escaping { in custom module code
Actually, what I'm seeing in the "view source" of the web page for that line is
HTML Code:
<script type="text/javascript">stLight.options();</script> |
Re: Escaping { in custom module code
Quote:
Exactly. Anyway, approach I suggested above should help. |
Re: Escaping { in custom module code
Thanks for helping with this Tony, I forgot about this thread. Tony has the right idea, just put the share code in a method inside the controller class and call it in the template.
|
All times are GMT -8. The time now is 04:22 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.