Solving IE7 hasLayout bug on Drupal 6 zen subtheme

To avoid content on second column jump over the left sidebar on links hover zoom:1 needs to be added to the #main division. I find that adding display:inline-block to the second sidebar has also helped on occasions.The exact problem and its solution is best described at: http://stackoverflow.com/questions/1144528/drupal-zen-subtheme-specify-stylesheets-for-non-internet-explorer-browsers

More on the hasLayout bug can be read at: http://www.bennadel.com/blog/1354-The-Power-Of-ZOOM-Fixing-CSS-Issues-In-Internet-Explorer.htm

Advertisements

Displaying a block based on the taxonomy term in the URL

I wanted to display node content in a block based on it’s taxonomy term’s URL, so that from example.com/exterior the user can see a list of nodes of term exterior. The problem is that blocks don’t pull arguments from the URL same way as a page view. This can be done by adding a term:ID argument, providing a default argument as php code. The following snippet takes the term id so that Drupal can use it as an argument for the content to be displayed:

//break path into an array
$path = explode(‘/’, $path);
$termname = array_pop($path);
//convert the dashes to spaces
$termname = str_replace(“-“, ” “, $termname);
$terms = taxonomy_get_term_by_name($termname );
$term = reset($terms);
return $term->tid;

More on this: http://drupal.org/node/781748#comment-2900002

Increse upload file size

If you don´t have access to the the php.ini file, Drupal can override the php.ini files values to increase the upload limit. This is done in the root´s .htacess file, by adding:
php_value upload_max_filesize 3M
php_value post_max_size 7M

…as explained in http://ykyuen.wordpress.com/2011/02/27/drupal-override-the-php-ini/

Views slideshow module IE issue

Each slide takes the bg color of the parent div (when it is not transparent), which causes problems on IE7 and 8. This can be fixed as explained in http://groups.drupal.org/node/85344#comment-266199

Multisite Drupal installation and virtualhosts

http://www.codeforest.net/multiple-virtual-hosts-in-wamp

Dynamic mp3 playlist in Drupal 6

I tried generating dynamic playlists with swftools or jw player module without success, but finally got Views to generate a playlist feed imported into an embedded mp3 player on the fly. These are the modules needed:

  • CCK + filefield (for the mp3 files)
  • Views bonus pack (to export fields to XML).

And the embeded mp3 player that I used can be found in http://www.premiumbeat.com/flash_music_players/.

The view filters by content of type song (in my case) and displays fields node title and the song content with a URL to file format. Adding a “path” as custom label for this last field helps to construct the correct xml tag for the mp3 player later. The view is displayed in a feed with a style of xml file and a path of playlist.xml for this example. At this point the supplied views-bonus-export-xml.tpl.php template file needs to be overriden to make it match with the xml file expected by the premiumbeat mp3 player (see the xml file that comes as an example with the player download). Instead of the <node> tags I used <item>, and I also needed to get rid of the <xml> tags and added <playlist>. The resulting file:

print '<?xml version="1.0" encoding="UTF-8" ?>';
?>
<playlist>
<?php foreach ($themed_rows as $count => $row): ?>
<item>
<?php foreach ($row as $field => $content):
$label = $header[$field] ? $header[$field] : $field;
?>
<<?php print $label; ?>><?php print $content; ?></<?php print $label; ?>>
<?php endforeach; ?>
</item>
<?php endforeach; ?>
</playlist>

The generated xml file looks like this:

<?xml version="1.0" encoding="UTF-8" ?><playlist>
  <item>
    <Title>song1</Title>
    <path>http://example.com/sites/default/files/song1.mp3</path>
  </item>
  <item>
    <Title>song2</Title>
    <path>http://example.com/sites/default/files/song2.mp3</path>
  </item>
</playlist>

The last thing needed is to embed in a block the player. The only thing we have to be careful with is the path, both to the xml playlist generated by the view and the actual mp3 player swf file.

<!--
BEGIN JAVASCRIPT PLAYER EMBED CODE
--><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<div id="player-holder">
&nbsp;</div>
<script type="text/javascript">
var options = {};
options.playlistXmlPath = "http://example.com/playlist.xml";


var params = {};
params.allowFullscreen = "true";
params.allowScriptAccess = "always";


swfobject.embedSWF("http:/example.com/sites/all/themes/mytheme/originalmultiple/OriginalMusicPlayerPlaylist.swf", "player-holder", "250", "180", "9.0.0",false, options, params, {});
</script><!-- END PLAYER EMBED CODE -->

That´s all!

Allowing bigger size file uploads

To allow for bigger size file uploads, as with large mp3 files, tweak the values post_max_size and upload_max_filesize in the php.ini file.

login & ckfinder issues: setting the $cookie_domain variable

I have experienced ckfinder permission issues that are resolved by uncommenting and setting the $cookie_domain variable in the settings.php file to the domain name. If this is not configured right can lead into login issues (“Access denied…”). What works for me is to set up the variable as follows:

$cookie_domain = ‘.mydomain.com’;

It is important to note that the dot after the comma can´t be forgotten.

This issue was explained and resolved here: http://drupal.org/node/884458#comment-3445520

drop down menus in drupal 6

Using nice menu module is needed to achieve a drop down menu effect. It needs to be enabled and assigned to a region where the navigation bar is. If using zen theme, overflow:hidden style in layout-fixed.css file for selector #navigation (line 226) needs to be removed. In the page.tpl.php file, instead of printing $navigation we need this line: . Css styling foes the rest.

Trimming text in a teaser causing issue

If a user adds html code to style content, like adding bold or italics for some text, and a view is displaying a teaser of that particular content trimming text down to say 100 characters, it can happen that closing tags are left out therefore extending italics or bold style to the rest of the page. This can be easily solved by making sure that each view that contains a teaser displayed has set either “Field can contain HTML” option (which will ensure tags are properly closed) or “Strip HTML tags”, which will output just plain text for the teaser view. An example of this and its solution was reported on:

http://groups.drupal.org/node/74833