Helpful regexs for stripping extranous styling

Content migration is a pain, particularly when you are charged with copying content from an old html site into a new framework. Often times, old content comes with the baggage of inline css styling, which wreaks havoc on your pretty new site design. Here's a handful of helpful regexs that I use to strip out undeed inline styling, while still preserving the html element structure.

To strip out span tags:

<span[^>]+>

Follow up to strip out the close tags:


Joomla: dynamically adding stylesheets by category and section

I once had the misfortune of developing a Joomla site with three separate templates, each of which contained four separate color schemes. The color scheme needed to be selected based on the content's section and/or category.

This PHP script will cycle through various methods for determining category id, section id, or content id. It also includes an array for manually setting the stylesheet by id.

<?php
//get article id

//look for article id in get variable id

Views Accordion - Opening a specific row with a link

Goal: create link that goes to a new page and opens a specific accordion drawer.

Using the Views Accordion module in combination with a little custom code accomplished this. Here's a step by step guide.

Create your view

-add this header with input filter "php code":

<?php
$view = views_get_current_view();
$nid_arg = $view-> args[0];
?>
<?php if ($nid_arg): ?>

<?php print $nid_arg; ?>

<?php endif; ?>

Customizing the filefield format in views

Often times, you may want to customize the appearance of a views field, or perhaps add a bit of logic to the output. You can customize the display of any field in Views by utilizing the Views Customfield module.

Here's an example of how to breakdown a basic cck fieldfield into its constituent parts.

<?php
//print var_export($data, TRUE); //prints out all available fields in view

$value = $data->node_data_field_document_field_document_fid; //relevant fid

if ($value != NULL){