How to add variable and do loop in CSS - css

Is it possible to add variable and do loop in css like php:
for($a=6; $a<9; $a++) { "#divShow"+$a }
So, the result will be:
#divShow6 #divShow7 #divShow8
Any idea? Thanks in advance.

No. There are no 'variables' or 'loops' in CSS. It is not a Turing-complete language. This is what CSS classes are for, so you don't have to generate IDs.

You don't have loops in CSS, but if you want to match all the tags with an id that starts with divShow you can use (example http://jsfiddle.net/diegof79/mUGsj/):
div[id^="divShow"]
But I'll recommend to use a class instead.
Also your question shows a match of childrens: divShow8 inside a divShow7. You don't need that kind of selector, because probably the problem can be resolved in another way (by using classes or different id).
Take a look to http://www.w3schools.com/cssref/sel_nth-child.asp maybe it gives you other ideas.

Related

Extract number data from HTML with RobotFramework

I need to extract a number from an HTML page and convert it into a variable in my test case.
The problem is that there is no ID directly to this element, here is the HTML code, I want to get the 54 (that number can change that's why I need to identificate him with another way), I tried Get Text by using "resultat" but I get "54 ligne(s) trouvée(s)" but I only want "54":
<div class="tab-interpage> == $0
<div class="resultat">
<b>54</b>
ligne(s) trouvée(s)
</div>
...
You have other options how to locate an element, see Locating elements section in Selenium Library.
This might be a situation that requires xPath, I can imagine this one works (but I don't see the whole DOM, so I can't be 100 % sure):
//div[#class="resultat"]/b
combined with the keyword:
${var}= Get Text //div[#class="resultat"]/b
Obviously if there're more div elements with class "resultat", you might run into problems here. In this case, explore the DOM a bit more and see what are some other ways you can get to the element you need.
I think it'd be much more readable if the HTML elements had proper attributes like:
form with class attribute
unique ids usually work best

capturing a child value in Firebase rules

Using Firebase, it's possible to create rule expressions tp protect data but I've found it can quickly become complex.
One case I'm looking at has a rule using the children of the current node, e.g.:
data.child('value').val() === true
It's also possible to create a rule based on the contents of another node:
root.hasChild($node_variable)
What I'd like to do is to combine these two, e.g.:
root.child(data.child('value')).hasChild($node_variable)
but this hybrid approach throws an error when I publish the combined rule. Is there a way around this?
As suggested by David in the comments, the solution was
root.child(data.child('value').val()).hasChild($node_variabl‌​e)

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

Less override variable just for one country (language)

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.

CSS Attribute Selcetor - Which one is faster?

Which one is preferred in terms of performance?
a[href*="op.ExtSite.com/p"]
a[href*="shop.ExtSite.com/page"]
a[href^="http://shop.ExtSite.com/page"]
a[href^="http://shop.ExtSite.com/page"][href$=".html"]
Update
The last selector should have been written as follow:
a[href^="http://shop.E"][href$=".html"]
Also, regarding this multiple selector, I would like to know which condition is checked first, the left one or the right one?
My guess is either this one
a[href^="http://shop.ExtSite.com/page"]
or
a[href^="http://shop.ExtSite.com/page"][href$=".html"]
as it starts looking from the first of the string so all links that does not have h in the beginning will be avoided.
UPDATE
if you need to check on the full pattern then go with the one I mentioned below :
a[href^="http://shop.ExtSite.com/page.html"]

Resources