Project:jCarousel
Version:6.x-2.4
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

I would like to create a custom skin for 6.x. I did this in 5.x, and placed the skin in 'sites/all/includes/jcarousel/skins/custom.' However, in 6.x, the module does not require the 'includes' folder. I assume that I can place the skin in 'modules/jcarousel/skins/custom.' This means that when I update the module, I need to reupload the skin.

So, the question: can I place the skin in a separate folder in my sites folder? this way, it will not be overwritten. If the answer is yes, can you specify:
1. where I can put it (that actual folder name)
2. what I need to add in the jcarousel_add().

I will write this up as documentation which can be added to the read me. It would help for the read me to be specific to drupal, not simply jcarousel in general (the documentation for that is great!)

Comments

#1

Hi,

Took me some time, the document is sparse and I had to dig the code to understand it.
Here is a sample of what worked for me:

<?php
// Create an array with HTML data ( I used imagecache but its not necessary )
$images = array();
  foreach (
$field_gallery_image as $key => $value) {
 
$images[] = "<a href='/blabla'>".theme('imagecache', 'gallery_thumbs', 'gallery_raw/'.$value['filename'], $value['data']['alt'], $value['data']['title'])."</a>";
}

// Options to pass to the carusel
$options = array(
"visible" => 9,
"scroll" => 1,
"wrap" => "both",
);

// Build the carusel
print theme('jcarousel', $images, $options, "gallery", "sites/default/themes/raphael/jskins/gallery.css", 'horizontalcarousel');
?>

** Note that the custom skin path must never start with a / **

#2

Status:active» closed (fixed)

In the 2.x version of the module, you can put skins into a custom module by implementing hook_jcarousel_skin_info(). See the jcarousel_jcarousel_skin_info() function in jcarousel.module for an example of how to do this. Alternatively, a good approach is simply to place your skin CSS directly in style.css and then pass in the name of your skin as an option into theme('jcarousel') or jcarousel_add(), since the skin is really just a class on the UL.

I'm going ahead and closing this issue directly due to its age and inactivity.

#3

Can you override the hook_jcarousel_skin_info() from within a theme?

I am overriding it in my template.php and it doesn't register:

/**
* Implements hook_jcarousel_skin_info().
*/
function mytheme_hook_jcarousel_skin_info() {
  $skins = array();

  $skins['default'] = array(
    'title' => t('Default'),
    'file' => 'skins/default/jcarousel-default.css',
  );
  $skins['tango'] = array(
    'title' => t('Tango'),
    'file' => 'skins/tango/jcarousel-tango.css',
  );
  $skins['myskin'] = array(
    'title' => t('My Skin'),
    'file' => 'skins/myskin/jcarousel-myskin.css',
  );

  return $skins;
}

Any clue why?
Thanks

#4

Status:closed (fixed)» active

#5

Can you override the hook_jcarousel_skin_info() from within a theme?

No you cannot, as themes cannot implement hooks (other than hook_theme and hook_theme_alter). I thought about how we could make this possible, but it turns out to be nearly impossible. Consider what would happen if you had enabled an admin theme that was different from your front-end theme. Or if you were using some kind of theme-switcher module to change the theme based on some condition. You can only have one theme loaded at a time, so if you told views to use the skin from "theme A" but "theme B" were actually being used to load the page, the skin wouldn't work because "theme A" can't be loaded at the same time as "theme B".

Hence why (once again), I insist that the concept of "skins" is completely dumb and you should just not use a skin at all and include the necessary CSS directly in style.css or add a jcarousel.css to your theme's info file.

#6

I think, that one textfield should be added on settings page of this module, where we will can type our manual skins of jcarousel, like this:

skins/default/jcarousel-default.css,skins/tango/jcarousel-tango.css,skins/myskin/jcarousel-myskin.css

and replace code in function jcarousel_jcarousel_skin_info() with something like this:

$skins = array();
$skins_settings = expode(',', variable_get('jcarousel_skins_settings','skins/default/jcarousel-default.css,skins/tango/jcarousel-tango.css'));
foreach($skins_settings as $key => $setting) {
$skins[] = array(title' => $key, 'file' => $setting);
}
return $skins;

#7

Not to the API, but this worked for me:

The 'xxx' folder is copied from one of the 'jcarousel/skins' folders and placed in my custom module's 'www' folder.

  drupal_add_css(drupal_get_path('module','zzz').'/www/xxx/skin.css','file');
  jcarousel_add('jcarousel-skin-xxx', array(
      'animation' => 'slow',
      'easing' => 'swing',
      'scroll' => 1,
      'itemFallbackDimension' => '180px',
  ));
  $form['time_scrollable_navigator'] = array(
      '#markup' => '
          <ul id="mycarousel" class="jcarousel-skin-xxx">
              <li class="deleteme"></li>
              <li class="deleteme">Loading schedule data...</li>
              <li class="deleteme"></li>
              <li class="deleteme"></li>
              <li class="deleteme"></li>
          </ul>');

#8

Version:6.x-1.1» 6.x-2.4

For version 6.x-2.4:

If you want to set things up so that you can select a custom skin via jcarousel settings in views, make a custom module and use hook_jcarousel_skin_info()

For example:

<?php
/**
* Implements hook_jcarousel_skin_info().
*/
function my_module_jcarousel_skin_info() {
 
$skins['myskin'] = array(
   
'title' => t('My Skin'),
   
'file' => 'jcarousel/skins/myskin/jcarousel-myskin.css',
  );

  return
$skins;
}
?>

Note that you should place all the skin's files inside your custom module's folder. In the example above, the jcarousel folder would be inside a module folder called my_module

#9

Status:active» closed (duplicate)

Thanks wuh! That's a very good start on decent documentation. Let's merge this issue with #393562: More Documentation on creating skins, which is the same topic.

nobody click here