drupal

Drupal - Jcarousel and views

Adding a Jcarousel effect to a <ul> of a block view.

Install jquery_update module.
Download Jcarousel. Unzip to theme folder.

Create a block view, than publish it.

Add this snippet inside the <head> part of page.tpl.php:

   <script type="text/javascript" src="<?php print base_path() . path_to_theme() ?>/jcarousel/lib/jquery.jcarousel.pack.js"></script>
    <link rel="stylesheet" type="text/css" href="<?php print base_path() . path_to_theme() ?>/jcarousel/lib/jquery.jcarousel.css" />
    <link rel="stylesheet" type="text/css" href="<?php print base_path() . path_to_theme() ?>/jcarousel/skins/tango/skin.css" />
    <script type="text/javascript">
jQuery(document).ready(function() {
$("div.view-class-name").find("ul").attr("id","jcarousel");
$("#jcarousel").addClass("jcarousel-skin-tango");
$("#jcarousel").jcarousel({
vertical: true,
scroll: 1
});
});
    </script>

List of options you may set

Via drupal.org forums. Posted here for reference.

Drupal - Hide a block for a specific node type

I needed to hide a block for a certain node type on a drupal driven website so i found this snippet on drupal.org. I will post it here for my future needs.

Paste this in "Page specific visibility settings" tab on the block you want to hide. Select "Show if the following PHP code returns TRUE (PHP-mode, experts only)." first.

<?php
$match = TRUE;
$types = array('story' => 1);
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  $type = $node->type;
  if (isset($types[$type])) {
    $match = FALSE;
  }
}
return $match;
?>

Syndicate content