Less override variable just for one country (language) - css

The context of my problem :
I have a website multi-language ( 20 ), I use less css.
All stylesheets are common, except one for every country called to the end.
I have a file com.base.less which has a variable of font.
Every stylesheet calls this file to use the variables which it contains.
My question, for a country I must change the font, thus to re-declare the variable only for this country.
How can I proceed?
Because if I re-celare my variable in my file of country, that this being called to the end it isn't written again.
I use lessPhp, and I see ModifyVars but I don't know if it's good method ?
(when I test he doesn't work)
Thank you

Yes, as the docs tell you "You can use the ModifyVars() method to customize your CSS if you have variables stored in PHP associative arrays".
Less uses the last declaration wins rule for variables, so the last re-declare value of variable at the end of your code will be used everywhere in your code.
I use lessPhp, and I see ModifyVars but I don't know if it's good
method ? (when I test he doesn't work)
Make sure that you call ModifyVars() before getCss() and call both on the same instance of Less_Parser.

Related

Where handle parameter value from wp_enqueue_style come from?

Relative to the wp_enqueue_style() In documentation says:
(string) (Required) Name of the stylesheet. Should be unique.
But this is not clear to me if is a value you need to give to set a unique reference in the moment to enqueue the styles or you need to pick it up from the file name or directory.
Where this value come from?
To me is not clear in documentation. I've read some tutorials about it, but still is not clear to me.
You should give a unique name for your script, e.g:
wp_enqueue_style('myCustomStylesheet12345', 'path_to_stylesheet/stylesheet.css);
For example:
If you later try to enqueue something with the same given handle, it wont be added. (you have to add unique name for both, or remove previous if already enqueued before enqueue the second one.)

Prestashop 1.6 / How to get carrier id, to use it in order-carrier.tpl

I'm using Prestashop 1.6
In order-carrier.tpl, I'm trying to get the carrier id, because I would like to use it in the css class of the <div>.
For exemple : div.delivery_option.carrier_id_33
I tried this :
{$cart->id_carrier}
But it doesn't really work.
If it's in TPL file, you need to use getcontext() first
So in this case it would be
{context::getContext()->cart->id_carrier}
Late answer here, but I write mainly for future reference.
First, there should always be a global $carrier smarty variable available to templates. Just check placing a {debug} tag on the place you want to use it and see if it's there.
Second, DO NOT use id_carrier. It's quite strange but you will loose it. It's not a really reliable property. I discussed the issue with the developers some time ago. You should use id_reference instead: that won't change.
http://forge.prestashop.com/browse/PSCSX-4651
So, to sum up:
{assign var=carrier_instance value=$carrier.instance}
{* then later somewhere: *}
{$carrier_instance->id_reference}
this will do the job.
Try this code
<div class="delivery_option {if ($option#index % 2)}alternate_{/if}item {foreach $option.carrier_list as $carrier}carrier_id_{$carrier.instance->id}{/foreach}">
The carriers are not directly accessible, but they are encapsuled inside the variable $option
Since I always get here whenever I search for id_reference from smarty I'll post my solution for 1.7
{$carrier_id = context::getContext()->cart->id_carrier.id_reference}
Returns the carrier_id_reference, the nice one cause carrier_id changes everytime you modify a carrier, so the real ID you need in order to operate with carriers is id_reference

equal instruction inside SWRL rule not working

I am using Protege 4.3 to make some SWRL rules.
I have one class called "Person" with one property called "name".
I created individuals from the class with different names, and some names are the same.
I want to write a rule that creates instances of Property called "sameName" to bind people who have the same name. So I wrote the following rule :
Person(?p1), Person(?p2), name(?p1, ?n1), name(?p2, ?n2), equal(?n1, ?n2) -> sameName(?p1, ?p2)
The rule gave the right result but includes every person with himself, means compares also every person with himself, so I added notEqual(?p1,?p2) to force the reasoner to not compare a person with himself like this:
Person(?p1), Person(?p2), name(?p1, ?n1), name(?p2, ?n2), equal(?n1, ?n2), notEqual(?p1, ?p2) -> sameName(?p1, ?p2)
The result was empty. Did I miss something?
I guess you should set all the individuals be different.
If you did not do that, the reasoner could not judge whether two individuals are same or not, so the SWRL rules you wrote did not work at all.

Is it possible to intermix Modular templating and legacy VBScript CT?

In particular, the case I have in mind is this:
##RenderComponentPresentation(Component, "<vbs-legacy-ct-tcm-uri>")##
The problem I'm having is that in my case VBS code breaks when it tries to access component fields, giving "Error 13 Type mismatch ..".
(So, if I were to give the answer, I'd say: "Partially, of no practical use")
EDIT
The DWT above is from another CT, so effectively it's a rendering of component link, that's why parameterless overload as per Nuno's suggestion won't work unfortunately. BTW, the following lines inside VBS don't break and give correct values:
WriteOut Component.ID
WriteOut Component.Schema.Title
EDIT 2
Dominic was absolutely wright: it's a missing dependencies.
A bit more insight to make this info generally useful:
Suppose, the original CT looked like this ("VBScript [Legacy]" type):
[%
Call RenderComponent(Component)
%]
This CT was meant to be called from a PT, also VBS-based. That PT had a big chunk of "#include" statements in the beginning.
Now the story changes: the same CT is being called from another, DWT-based, CT. Obviously (thanks you all for your invaluable help!), dependencies are now not being included anywhere.
The solution to make original CT working again is to explicitly hand-pick and include all necessary VBS TBBs, so the original CT becomes:
[%
#include "tcm:<uri-of-vbs-tbb>"
Call RenderComponent(Component)
%]
Yes - it's perfectly possible to mix and match legacy and modular templates. Perhaps obviously, you can't mix and match template building blocks between the two techniques.
In VBScript "Error 13 Type mismatch" is sometimes used as a secret code that really means "I don't recognise the name of one of your variables, (including the names of Functions and Subs)" In the VBScript templating engine, variables from the page template could be in scope in your component template; it was very common, for example, to put the #includes in the PT so they could be used by the CT. My guess is that your component template is trying to use such a Function, and not finding it.
I know that you can render a Modular Page Template with VBScript Component Presentations, and also a VbScript page template can render a modular Component Template.
Your error is possibly due to something else? Have you tried just using the regular ##RenderComponentPresentation()## call without specifying which template?
The Page Template can render Compound Templates of different flavors - for example Razor, VBS, or XSLT.
The problem comes from the TBBs included in the Templates. Often the Razor templates will need to call functions that only exist in VBScript. So, the starting point when migrating templates is always to start with the helper functions and utility libraries. Then migrate the most generic PT / CT you have to the new format (Razor, XSLT, DWT, etc). This provides a nice basis to migrate the rest of the Templates as you have time to the new format.

Is it possible to declare a default associative array in Smarty?

In Smarty, I know you can declare a string:
{$somevar|default:'some string'}
or even an array:
{$somevar|default:array('someval')}
How do you/Is it possible to set an associative array as a default value? as this doesn't seem to work:
{$somevar|default:array('default'=>array('subkey'=>'subval'))}
I just tried:
{$somevar|default:array('key'=>'val')}
It's the '=>' smarty doesn't like
I know its probably not the solution you're looking for, but you can always just use the {php} feature. However, I will try a few things and see if I can work the format out.
Just out of interest, why are you trying to do this in the tpl file and not in the calling PHP script?
Edit
From takeing a read, it doesn't seem like it is possible. However, there is a "set" plugin which allows it, see here (bottom example).

Resources