Drupal's ability to preprocess HTML code in your theme's template.php file is extremely helpful for theme coding and site administration.You can find excellent preprocessing scripts on Drupal.org's forums, or simply use one of the many free Starter Theme such as Zen or Basic. I personally use the Basic Theme, which does quite a lot of theming work for you.
I could write a tutorial on how to use Views' two most nefarious arguments, "Taxonomy: Term ID (with depth)" and "Taxonomy: Term ID depth modifier," but I won't. There are plenty of those. Instead, I'll just tell you how not to use them.
If you're like me, you'll get very excited when you see a URL that looks like
http://www.mywebsite.com/taxonomy/term1-name/term2-name. It will fool you into thinking that you can create a view which accepts infinite taxonomy term arguments, each separated with a pretty slash. Well you can't. At least, not exactly.
I'll be the first to admit that this code snippet was not the ideal solution to my problem, but sometimes I take shortcuts. I know. It's terrible.
Here's a little jQuery snippet that I use often. It lets you easily specify a 'hover-state' image for any html element with class 'rollover.' Just set the rel attribute to equal the rollover image, and the src attribute to equal the original.
//rollover swap images with rel var img_src = ""; var new_src = "";
The jQuery validation plugin is an excellent tool for validating forms. The online documentation is actually quite extensive, but I found it difficult to locate any example code that really showed a full implementation of the plugin with all of its methods. After a lot of collaborative work, I've written an implementation of this plugin that manages to use most of the of customizable methods.
Just a quick note to other siteground users with ssh access to their shared hosting accounts: Drush can work via the command line in a siteground environment. Here are some specific settings that I had to include to get it to work:
alias drush='/usr/local/php52/bin/php-cli ~/drush/drush.php --php=/usr/local/php52/bin/php-cli'
I'm a total linux noob. So when I tried to manually set up Drush on a Linux server today, I ran into a bit of trouble. Following the Drush instructions, I put drush outside of the webroot and attempted to create a symbolic link between the Drush directory and /usr/bin.
The drush readme instructs a noob to do the following:
ln -s /path/to/drush/drush /usr/bin/drush
So, I navigated to the drush directory and tried to follow instructions:
ln -s drush /usr/bin/drush
Here's a useful Jooma template coding, php snippet:
countModules('position1')) : ?>
This will only show position 'position1' and its wrapping div if the position contains a module.
After using Drupal's template.php file to preprocess html and add unique classes to various html elements, I because very dependent on page specific css classes. While building a Ruby on Rails app, I thought it would be nice to at least add in a page-specific body class. Here's a quick snippet you can use:
<% page = request.request_uri.gsub(/^(\/)?/, '') page = page.gsub(/\//, '-') %> ">
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:
Follow up to strip out the close tags:
Strip out inline styling: