| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
#1
|
|||||||
|
|||||||
js in tpl
hey guys,
I'm trying to figure out how to add js (specifically json) to a tpl file. in xc4 I just used {literal}{/literal}, but that appears not to work here. how do I add a json string to the js in a tpl without triggering flexy to want to parse it?
__________________
SEEK HAPPINESS. EVERYTHING ELSE IS DETAILS. |
|||||||
#2
|
|||||||||
|
|||||||||
Re: js in tpl
You need to do it with custom module - this should help http://kb.x-cart.com/display/XDD/Developer+docs
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#3
|
|||||||
|
|||||||
Re: js in tpl
Quote:
I already have a custom module. my code is in my custom module. the issue is that inside the tpl I need to add a json string: window._fbq.push(['track', '00000000000000', {'value':'0.00','currency':'USD'}]); which obviously is wrapped in {} so it's getting interpreted.
__________________
SEEK HAPPINESS. EVERYTHING ELSE IS DETAILS. |
|||||||
#4
|
|||||||||
|
|||||||||
Re: js in tpl
Don't put it in tpl file, make a class to return it. That way flexy is not involved in outputting the code, only to call the class and print out the return whatever it is.
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#5
|
|||||||
|
|||||||
Re: js in tpl
Quote:
that just seems like overkill to drop some fb code on a page. it's the one thing I really don't like about xc5. I'm gonna call that option 2 lol.. thanks for the feedback does flexy not have an equivalent to smarty's {literal} tag?
__________________
SEEK HAPPINESS. EVERYTHING ELSE IS DETAILS. |
|||||||
#6
|
|||||||||
|
|||||||||
Re: js in tpl
Yes there is a lot of going back and forth between tpl and php files in XC5. I am not sure if this is just the way XC5 is coded to work or this is a result of using MVC model, Doctrine and flexy. It is overkill and confusing but it is the way to do it. I don't believe flexy has alternative to smarty's literal tag
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
|
#7
|
|||||||||
|
|||||||||
Re: js in tpl
Flexy usually ignores JavaScript. But sometimes I've had to format it "correctly". By that I mean:
This will get mangled by Flexy: Code:
And this won't: Code:
I'm not sure if that is true with those exact snippets, just using them as an example. You could try: Code:
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey XcartGuru X-cart Tutorials | X-cart 5 Tutorials Check out the responsive template for X-cart. |
|||||||||
|
#8
|
|||||||
|
|||||||
Re: js in tpl
Quote:
OMG! Mike, you rock so much! that did it!
__________________
SEEK HAPPINESS. EVERYTHING ELSE IS DETAILS. |
|||||||
|
#9
|
|||||||||
|
|||||||||
Re: js in tpl
That is odd. So flexy goes line by line completely ignoring next/prev lines and caring only about the current one...
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#10
|
|||||||||
|
|||||||||
Re: js in tpl
It's the whitespace, for example:
{data} is parsed { data } isn't Code:
|
|||||||||
|
|
|||
X-Cart forums © 2001-2020
|