Keyword

i want to add style condition to the css style

  • Mhad Morph
  • Mhad Morph's Avatar Topic Author
  • Offline
  • New Member
More
9 years 1 month ago #153034 by Mhad Morph
hello
i want to add style condition to the css style
for example
i have k2 content , if the language is en i want specific style
of the language ar i want specific language

Please Log in or Create an account to join the conversation.

More
9 years 1 month ago #153042 by Javi Mata
Replied by Javi Mata on topic i want to add style condition to the css style
if know modified your templates can add some like this:

$lang = JFactory::getLanguage();
$classLang = "item-" . $lang->getTag();

and add this variable in the class of the div

Twitter: @Javi_Mata
Web: www.javimata.com

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 1 month ago #153063 by Krikor Boghossian
Replied by Krikor Boghossian on topic i want to add style condition to the css style
Javi has proposed a smart solution,
remember to use overrides instead of editing core files as well.

getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

Please Log in or Create an account to join the conversation.

  • Mhad Morph
  • Mhad Morph's Avatar Topic Author
  • Offline
  • New Member
More
9 years 1 month ago #153142 by Mhad Morph
Replied by Mhad Morph on topic i want to add style condition to the css style
thank you very much for replay .
but can you be more specific , were to but this code and how to select a lang.

Please Log in or Create an account to join the conversation.

  • Mhad Morph
  • Mhad Morph's Avatar Topic Author
  • Offline
  • New Member
More
9 years 1 month ago #153145 by Mhad Morph
Replied by Mhad Morph on topic i want to add style condition to the css style
thank you very much for replay .
but can you be more specific , were to but this code and how to select a lang.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 1 month ago #153157 by Krikor Boghossian
Replied by Krikor Boghossian on topic i want to add style condition to the css style
This is template specific so I cannot share precise code.
This code needs to be applied on the module's override.

(/templates/YOUR_TEMPLATE/html/mod_k2_content/YOUR_K2_CONTENT_TEMPLATE)

Please Log in or Create an account to join the conversation.

  • Mhad Morph
  • Mhad Morph's Avatar Topic Author
  • Offline
  • New Member
More
9 years 1 month ago #153181 by Mhad Morph
Replied by Mhad Morph on topic i want to add style condition to the css style
thank you for reply i ask how to choose a class or lang from this code
i try it and it and not work even with standard joomla

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 1 month ago #153195 by Krikor Boghossian
Replied by Krikor Boghossian on topic i want to add style condition to the css style
Check my reply on the other thread if the issue is only related to text direction.

Please Log in or Create an account to join the conversation.

More
9 years 1 month ago - 9 years 1 month ago #153200 by Javi Mata
Replied by Javi Mata on topic i want to add style condition to the css style
the best is, create a override template in the folder html of your template, like tell you Krikor

in this template, in the file category.php can do it this:

<?php
$lang = JFactory::getLanguage();
$classLang = "lang-" . $lang->getTag();
?>

<div id="k2Container" class="<?php echo $classLang; ?> itemListView<?php if($this->params->get('pageclass_sfx')) echo ' '.$this->params->get('pageclass_sfx'); ?>">

with this you add a class lang-XXX where XXX is the language tag, with this you can add in your css the class for each language

sorry if can explain more, i don't speak english :-D

Twitter: @Javi_Mata
Web: www.javimata.com
Last edit: 9 years 1 month ago by Javi Mata.

Please Log in or Create an account to join the conversation.

More
9 years 1 month ago - 9 years 1 month ago #153214 by JoomlaWorks
Replied by JoomlaWorks on topic i want to add style condition to the css style
Or you could do everything purely in CSS.

Joomla (and I hope your template) is already outputting a language identifier on the <html> tag. If it doesn't, see how the "system" template under /templates/system/index.php does it and copy it to your template.

Then you can use the :lang() pseudo selector (as old as the CSS 2.1 spec): css-tricks.com/almanac/selectors/l/lang/

Or you can use attribute selectors like this (info here: css-tricks.com/attribute-selectors/) like this:
html[lang="en-gb"] #someElement p {color:red;}
html[lang="fr-fr"] #someElement p {color:blue;}

:)
Last edit: 9 years 1 month ago by JoomlaWorks.

Please Log in or Create an account to join the conversation.

  • Mhad Morph
  • Mhad Morph's Avatar Topic Author
  • Offline
  • New Member
More
9 years 4 weeks ago #153377 by Mhad Morph
Replied by Mhad Morph on topic i want to add style condition to the css style
thank you all guys my problem solve

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 weeks ago #153386 by Krikor Boghossian
Replied by Krikor Boghossian on topic i want to add style condition to the css style
You 're welcome Mhad.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum