Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add media='screen' in css using cakePHP?

Tags:

css

cakephp

<?php
    echo $this->Html->css(
        array(
            '/printPlugin/css/960',
            '/printPlugin/css/screen',
            '/printPlugin/css/print',
            '/printPlugin/src/css/print-preview'
          )
        );
?>

This code produce following HTML:

<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/960.css" />
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/screen.css" />
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/print.css" />
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/src/css/print-preview.css" />

My expected output is:

<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/960.css"  media="screen"/>
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/screen.css" media="screen"  />
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/css/print.css" media="print" />
<link rel="stylesheet" type="text/css" href="/demo-home22/printPlugin/src/css/print-preview.css" media="screen"/>

That means I would like to add media="screen" in each CSS link.

N.B: I am using cakePHP 3

like image 200
Abdus Sattar Bhuiyan Avatar asked Dec 19 '22 22:12

Abdus Sattar Bhuiyan


1 Answers

Here you can use

<?php echo $this->Html->css(['mycss'],['media' => 'print']); ?>

Output will like this html

<link rel="stylesheet" href="/myproject/css/mycss.css" media="print"/>
like image 130
Alimon Karim Avatar answered Dec 30 '22 05:12

Alimon Karim