-
1. Re: Liquid render questions
Liam Dilley Jul 8, 2014 11:15 PM (in response to Liam Dilley)Bug? Doing something wrong?
I may be doing this wrong but if you have a web app in a layout, like the large product layout.
And in the list layout of the web app you have:
{{this.name}}
This renders the name of the product and not the name of the web app as I expected. I assumed that this. was in context to the layout / BC part it is in?
{{name}} also renders the product name not the web app name.
EDIT:
I found the tags did not work either, But I made some changes to the large product layout and then it rendered correctly. Just some glitches but hopefully this info may help to identify what this may be.
-
2. Re: Liquid render questions
Liam Dilley Jul 8, 2014 11:48 PM (in response to Liam Dilley)You can declare a custom value:
{% assign somevar = 'Sale Terms and Conditions ' %}
and if you have a web app in a layout inside a large product layout for example you can fetch that global variable..
{{somevar}}
And you can use..
{% assign my_variable = false %}
{% if my_variable != true %}
This statement is valid.
{% endif %}
In any layout
But how do you get a global variable in an if?
{% if global.somevar == 'Real Cotten' %}
Does not seem to work, nor does just having somevar
Is it something like global.variable.somevar ?
-
3. Re: Liquid render questions
Lucian Cozma Jul 9, 2014 1:22 AM (in response to Liam Dilley)"globals" is the name of the variable and is always available in the "this" scope also.
So you can either use {{this.globals....}} or directly {{globals....}} (this is optional and is just a container for the current scope).
In "globals" you can have: {{globals.get...}} {{globals.cookie}} {{globals.site}} {{globals.user}} {{globals.visitor}}. Just do a {{this.globals | json}} (or {{globals | json}}) in a page to see what is available.
-Lucian
-
4. Re: Liquid render questions
Lucian Cozma Jul 9, 2014 1:25 AM (in response to Liam Dilley)Passing liquid parameters to the module does not work in this release. We have already implemented this, and it will be available with the next release (most likely early next week).
Once we release the update you will be able to do {module_webapps id="{{somevar}}" filter="item" itemId="4784932" hideEmptyMessage="true" }
-Lucian
-
5. Re: Liquid render questions
Lucian Cozma Jul 9, 2014 1:30 AM (in response to Liam Dilley)Variable assignment does not carry in the global scope.
So doing an assignment like {% assign myVar = "value" %} will only be visible in the current scope (aka: template).
If you need to pass this variable into a sub-module, you will have to pass it as an extra parameter to the included module (we have this working also, will be available with the next update).
We will add the possibility to add extra-parameters to any module and you will be able to access the parameters via a {{this.params.paramname}}:
if you have a template with:
{% assign myVar = "value" %}
{module_webapps id="mywebapp" filter="item" itemId="4784932" hideEmptyMessage="true" myExtraParam="{{myVar}}"}
Then in the layout of the webapp you will be able to use {{this.params.myExtraPram}} (or directly {{params.myExtraParam}}).
-Lucian
-
6. Re: Liquid render questions
Lucian Cozma Jul 9, 2014 3:31 AM (in response to Liam Dilley)Liam, can you give more details on how to duplicate this (maybe some sample files on how you're doing this)?
I've tried to duplicate this and cannot (things render properly).
I've placed a webapp item in the large product detail page and {{this.name}} that is in the large product detail layout renders ok and same for the {{this.name}} in the webapp layout.
I've even tried placing the webapp item in the actual product description and it also works ok.
-Lucian
-
7. Re: Liquid render questions
Liam Dilley Jul 9, 2014 3:55 AM (in response to Lucian Cozma)In testing Lucian, You actually can passed assigned variables through.
In my case I could assign a variable in the large product layout, change it based on conditions and if a web app is in that layout, in the list layout of that web app it would render.
The only elements that would not work are the operators like the if.
On that intended or not it does work, I am not sure if you want to prevent that from working to avoid confusion? Or make sure documentation states not to do it that way.
I hear you on the this.params.paramname - That was I tried as well so good to know it will work and I like how you have presented that. I can let people know in the webinar this and that it is coming.
My goal on this stuff are to avoid what I have for our webinar demo where you are doing an if this - render module, if that - render module. As you noted to me that this all counts. While your increasing the modules, My goal is always to be efficient with my code.
If I can just run one web app and vary parameters and operators etc then I am a happy man.
-
8. Re: Liquid render questions
Liam Dilley Jul 9, 2014 3:57 AM (in response to Lucian Cozma)In terms of the render issue I will try to look at this more. It just seems to not work sometimes and returns the parent. This may be a glitch but I will try see if I can get it more consistently failing.
-
9. Re: Liquid render questions
Lucian Cozma Jul 9, 2014 4:06 AM (in response to Liam Dilley)I understand now why you're saying that assigning a variable in the layout makes it available in sub-modules.
From what you're saying you're doing this in an overall layout (webapps or shop). Indeed, there you would get that effect. Overalls are rendered a bit more "special" than regular pages and this is (at least for now) a side-effect (I would not rely on this because of that).
If you will try this in a regular page and a module in that page you will see that this will not work (do assignment in the page and then try to use it in the module layout).
Using the mechanism to pass parameters to the modules is the way to go.
-Lucian
-
10. Re: Liquid render questions
Liam Dilley Jul 9, 2014 4:12 AM (in response to Lucian Cozma)Cool, thanks.
Again I think with Liquid being a server side OO language I think a "Best practise" Section of the documentation will be quite important.
"This does this but we recommend you do not do it like this, do it like that"
I know you do not have the documentation up saying you can do custom variables in liquid yet, but you know me, I will try stuff regardless and work it out.
-
11. Re: Liquid render questions
Liam Dilley Jul 9, 2014 10:14 PM (in response to Liam Dilley)Hey Lucian,
Are you guys working on as well to expose the same CRM information you can with modules?
{{globals.user.homephone}}
....
Down to the custom CRM fields?
-
12. Re: Liquid render questions
Lucian Cozma Jul 10, 2014 12:09 AM (in response to Liam Dilley)For now we're exposing just user.firstname, user.lastname, user.fullname, user.email, user.isLoggedIn.
-Lucian
-
13. Re: Liquid render questions
Liam Dilley Jul 10, 2014 4:39 PM (in response to Lucian Cozma)May I ask why?
It would be ideal to be able to tap into things so you could properly pull out a relationship for a person and their company for example
-
14. Re: Liquid render questions
Adam Cook Jul 28, 2014 10:04 PM (in response to Liam Dilley)I've got to agree with Liam on this.
-
15. Re: Liquid render questions
Liam Dilley Jul 29, 2014 9:01 PM (in response to Liam Dilley)Pagination:
Has this been implemented yet, How will this work?
Thoughts:
It would be great to have a named paramater in modules to disable the default {module_webapp pagination="false"
It would be great to then either run a collection or specify a type of pagination collection for the module so you can code your own.
pagination="mypagination" which overides the default and allows you to form an each loop for the pagination.
What have you guys discussed and got to on this?
-
16. Re: Liquid render questions
Liam Dilley Jul 31, 2014 2:35 AM (in response to Adam Cook)Collection & Json issues /questions.
Sample code:
{module_booking,a, collection="eventCollection"}
<script type="text/javascript" id="event-json">{{eventCollection.items | json}}</script>
Is fine because it will render the data in a script format.
I have a couple of questions/issues on this.
1. If you render a collection on the booking module, the collection works but the default module also still renders. I think this is a bug? You must supply an empty template parameter (Maybe worth documenting this clearly)
2. As with 2, if you render this as JSON data the default module still renders. Is it that things may work but some modules are not full converted?
3. When you render Json data it will render the html of any field with html in it, such as the description area. You can render in script and that is ok, but if you wanted to store in html data for example... data-value="" then it will render out that html. Is it possible to offer an escaped version of the json data?
I think I have found a few issues as well with Json and pulling description content with speach marks etc and not coming out as valid json as well.
- EDITED -
-
17. Re: Liquid render questions
Liam Dilley Jul 31, 2014 2:51 AM (in response to Liam Dilley)Can I ask where you guys are at in terms of exposing more of the Data from things like the CRM?
A number of us have been providing information on modules and tags and what data output is missing for a while on the current developer reference comments.
Is getting access to information we can not (Billing address on CRM not order, 2nd email, 3rd email, POBOX... etc) ?
Thanks
-
18. Re: Liquid render questions
Lucian Cozma Aug 7, 2014 7:57 AM (in response to Liam Dilley)Regarding #3: You can chain liquid filters for output: { { this | json | escape } }.
Regarding the json serialization not working properly due to some characters, can you provide some examples so we can duplicate/fix?
-Lucian
-
19. Re: Liquid render questions
Liam Dilley Aug 20, 2014 11:11 PM (in response to Lucian Cozma)Liquid Passing does indeed work now.
Shopping Cart and Registration:
Lucian, With Liquid, what will be available on the cart.
My Primary needs would be...
- Being able to access the product and ALL? (if possible) data via liquid
- Have the shipping options as a liquid or at least in a json format so we can form better custom solutions for this.
Same to with the checkout page. The Amount field is locked for good reason in terms of its value so you can not manipulate the price, even if you do BC will not take anything other then that current price.
I totally get why, but things like adding surcharges etc is a pretty much standard client request that BC developers can not do without going full API.
With liquid and being server side, is there something that can be offered here?
Further to these concepts:
Further to Liquid server side rendering, there must be some form of authenticated method or validation coupled with liquid to allow you to do a bit more or make requests and get information to do a bit more then just with javascript?
I know this sort of thing will be further down the line, but it is something that I think people will want going forward.
Thanks.




