Css Plugin

Posted

Css plugin for Simphple framework allows handle, from php, the css code of you website. Among Its features are: add css files and create css 'inline' classes in a html header, compress the css files and include them and create css files using simphple code.

An example

In the html header of you website only you must add an include structure towards the css template.

main.html
<html>
  <head>
    <title>Css example</title>
    <!-- INCLUDE "plugins/css/css_header.html" -->
    </head>
  <body>
  </body>
</html>
main.php
<?php
$dsf = new Sphp_Data_Store_File("cache/"truetrue);
$sphp = new Sphp_Template($dsf$options);
$css = new Css_Handler();

$css->add_file("public/css/style1.css");
$css->add_file("public/css/style2.css");

$class1 = new Css_Class("#id1 a"
    array("text-decoration" => "none""color" => "#33a"));
$css->add_class($class1);

$css->set_simphple_data($sphp);

$sphp->display_file("main.html");

?>
Resultado de ejecutar el archivo main.php
<html>
  <head>
    <title>Css example</title>
    <link href="public/css/style1.css" rel="stylesheet" type="text/css"/>
    <link href="public/css/style2.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
      #id1 a{ text-decoration:none; color: #33a;}
    </style>
    </head>
  <body>
  </body>
</html>

You can observe how from the php code you can add css files and css classes to the html code.

You click here for download css_pluign and see more examples and features.