{"id":1337,"date":"2018-01-19T19:22:43","date_gmt":"2018-01-19T19:22:43","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/php-enabled-stylesheets-page-7\/"},"modified":"2018-01-19T19:24:42","modified_gmt":"2018-01-19T19:24:42","slug":"php-enabled-stylesheets-page-7","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/php-enabled-stylesheets-page-7\/","title":{"rendered":"PHP enabled stylesheets Page 7"},"content":{"rendered":"<div class=\"phpbuilder-content\">\n<div class=\"phpbuilder-meta\">\n<div class=\"\">By Bertrand Potier<\/div>\n<div class=\"\">on November 24, 2002<\/div>\n<\/p><\/div>\n<div id=\"overflow-content\">\n<h2>The Real Fun!<\/h2>\n<div class=\"articleHeader2\">Code Generation<\/div>\n<div class=\"articlePara\">\nThis is the most obvious use of PHP inside a CSS stylesheet but not the one<br \/>\nwith the highest added value. One example is the creation of repetitive style<br \/>\ndefinitions like for the HTML headings, in\/decreasing the font size<br \/>\nautomatically from the font size set in the visual configuration file:\n<\/div>\n<div class=\"articlePhpEx\">\n<font face=\"courier\"><code><span style=\"color: #000000\"><\/p>\n<p><span style=\"color: #0000BB\">&lt;?php<br \/>\n<br \/><\/span><span style=\"color: #007700\">for\u00a0(<\/span><span style=\"color: #0000BB\">$i<\/span><span style=\"color: #007700\">=<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">;\u00a0<\/span><span style=\"color: #0000BB\">$i<\/span><span style=\"color: #007700\">&lt;<\/span><span style=\"color: #0000BB\">6<\/span><span style=\"color: #007700\">;\u00a0<\/span><span style=\"color: #0000BB\">$i<\/span><span style=\"color: #007700\">++)\u00a0{<br \/>\n<br \/>\u00a0print(\u00a0<\/span><span style=\"color: #DD0000\">'H'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$i<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'\u00a0{\u00a0'<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>\u00a0print(<\/span><span style=\"color: #DD0000\">'font-size:\u00a0'<\/span><span style=\"color: #007700\">.(<\/span><span style=\"color: #0000BB\">$VISUALS<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">$SkinID<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'page'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'fontsize'<\/span><span style=\"color: #007700\">]+(<\/span><span style=\"color: #0000BB\">6<\/span><span style=\"color: #007700\">-<\/span><span style=\"color: #0000BB\">$i<\/span><span style=\"color: #007700\">)));<br \/>\n<br \/>\u00a0print(<\/span><span style=\"color: #0000BB\">$VISUALS<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">$SkinID<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'page'<\/span><span style=\"color: #007700\">][<\/span><span style=\"color: #DD0000\">'fontunit'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">';'<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>\u00a0print(<\/span><span style=\"color: #DD0000\">'font-weight:\u00a0bold;'<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>\u00a0print\u00a0(<\/span><span style=\"color: #DD0000\">'\u00a0}'<\/span><span style=\"color: #007700\">);<br \/>\n<br \/>}<br \/>\n<br \/><\/span><span style=\"color: #0000BB\">?&gt;<br \/>\n<br \/><\/span><br \/>\n<\/span><br \/>\n<\/code><\/font><\/div>\n<div class=\"articlePara\">\nThe main advantage is for the lazy ones, not having to type the same thing<br \/>\nover and over again. More seriously, this can automate the creation of style<br \/>\ndefinitions in various situations and I&#8217;ll give more examples if requested. <\/div>\n<h2>Browser\/Platform Based Behaviors<\/h2>\n<div class=\"articlePara\">Usually, Javascript is being used in the index file of the web site in order<br \/>\nto detect the browser\/platform and load a different stylesheet. It happens that<br \/>\nthe difference between this and this browser\/platform specific stylesheet are<br \/>\nnot so big and being able to adapt a unique stylesheet would ease everything<br \/>\n(let&#8217;s avoid duplication). For example, font size (again) can be a problem<br \/>\ndepending on the Operating System (OS) of your visitor. Even at the same<br \/>\nresolution as on your WINDOWS OS, the text will appear to be smaller on Linux<br \/>\nand Mac OS platforms. I don&#8217;t have the chance to own a MAC OS so the value<br \/>\ntested may not be fully correct (extracted from <code class=\"example\">index.php<\/code>):\n<\/div>\n<div class=\"example\">\n<pre>\n\n&lt;script type=\"text\/javascript\" charset=\"ISO-8859-1\"&gt;\n var browser = navigator.appName.toLowerCase();\n var platform = navigator.platform.toLowerCase();\n var detect = ; if ( platform.indexOf(\"mac\") != -1 &amp;&amp; detect) {\n  location.replace(\"index.php?detect=false&amp;browser=msie6\");\n } \n&lt;\/script&gt;\n<\/pre>\n<\/div>\n<\/div>\n<p><\/p>\n<div style=\"float: left; padding:15px; color:#17AAF3\">\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"potier20021122c575.html?page=6\">\u00ab Previous Page<\/a><\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"potier20021122.html\">1<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"potier200211224658.html?page=2\">2<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"potier200211229ba9.html?page=3\">3<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"potier20021122fdb0.html?page=4\">4<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"potier20021122af4d.html?page=5\">5<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"potier20021122c575.html?page=6\">6<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"background-color:#B6E5FC; font-size:16px; margin-top:1px; padding:1px 4px 1px 4px; color:#000; font-style:bold; float:left;\">7<\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"potier20021122fdfa.html?page=8\">8<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"potier200211220b08.html?page=9\">9<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"potier200211221448.html?page=10\">10<\/a> <\/div>\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"potier20021122fdfa.html?page=8\">Next Page \u00bb<\/a><\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>From Perl scripts to PHP, a lot of technologies are today available to move HTML to the dynamic age but why not, going even further and do the<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1337","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/comments?post=1337"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1337\/revisions"}],"predecessor-version":[{"id":3223,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1337\/revisions\/3223"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=1337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=1337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=1337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}