Quantcast
Viewing all articles
Browse latest Browse all 2331

Extension Writers Discussion • Re: use php to add extra css class to existing class

Hello,

You could use BODY_CLASS.

Code:

$this->template->assign_vars(['BODY_CLASS'=> $spwclass,]);
Then declare the style accordingly.

Code:

.styleedits0 .headerbar {}.styleedits2 .headerbar {}.styleedits4 .headerbar {}...
That said, if it's just for a custom style, you don't need an extension.
Twig's date() filter does the job.

Code:

{% set classesname = [    'styleedits0', 'styleedits2', 'styleedits4', 'styleedits6',    'styleedits8', 'styleedits10', 'styleedits12', 'styleedits14',    'styleedits16', 'styleedits18', 'styleedits20', 'styleedits22'] %}{% set currenthour = "now"|date("H")|int %}{% set index = (currenthour // 2) %} {% set spwclass = classesname[index] %}<div class="headerbar {{ spwclass }}" role="banner">

Statistics: Posted by cabot — Thu Jan 30, 2025 2:15 pm



Viewing all articles
Browse latest Browse all 2331

Trending Articles