=====Using Wiki Pages as CSS Files===== This action allows any page on your wiki to be used as a CSS file. It will work even if the page contains a bunch of other wiki formatting. It simply extracts all of the code blocks with a type of css and inserts them into a "" %% Then save the following code as "customcss.php" inside of the actions directory: %%(php) tag == 'GlobalActions' || !$vars['apply']) return; $tags = array(); foreach ($vars as $var => $value) if (substr($var, 0, 4) == 'file') $tags[] = $value; $tags = join("','", $tags); $result = $this->Query('SELECT body FROM ' . $this->config['table_prefix'] . "pages WHERE tag IN ('$tags') AND latest = 'Y'"); if (mysql_num_rows($result)) while ($row = mysql_fetch_array($result)) $pages .= $row['body']; if (preg_match_all('|% %\(css\)(.*)% %|smU', $pages, $matches)) foreach ($matches[1] as $match) $css .= $match; echo $css; ?> %% **Please note:** "% %\(css\)(.*)% %" should actually be """%%\(css\)(.*)%%""" The "apply" parameter is just a hack that makes the action fail when the page is run through the formatter. All of the work is actually done in the header.php action. No need to do it again! Now drop something like this into a wiki page to get the whole thing working... %% {{customcss file="PageCSS"}} {{customcss file="AnotherCSSPage"}} %% If you would like the CSS to be included sitewide, drop it into a page named ""GlobalActions"". Don't worry about duplication, since any particular page will only be included once, no matter how many times it's listed. ====Authors==== DennyShimkoski ---- CategoryUserContributions