Hi All,

Firstly what a fantastic module. Forgive me if this is a really simple question, I am trying to use jcarousel to scroll through one of my aggregated feeds. I know this is possible because of the example on the jcarousel home page, however, I simply cannot replicate it. I can pull a feed out, but am totally lost at how to get the text entries to work. I have gone back to basics and just trying to get a static text feed working. I have all of the correct set-up, i.e. UL and LI entries as required.

<ul id="mycarousel" class="jcarousel-skin-tango">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
  <li>Item 4</li>
  <li>Item 5</li>
  <li>Item 6</li>
</ul>

I also have the JS in the header:

<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        // Configuration goes here
        vertical: true,
        start: 1,
        offset: 1,
        scroll: 1,
        wrap: "circular"
    });
});
</script>

I know this is not all that I need, I am simply having trouble following how to get this to work. I would appreciate and help.

Regards,
Nick

Comments

nickbits’s picture

Okay, I got the bit above figure, I was missing a couple of files. For some reason I didn't copy all of them when I installed it!

Next issue, I am trying to pull out a single category from my aggregated content. I have a couple of methods for doing this. The first is:

$q = $_GET['q'];
$_GET['q'] = drupal_get_normal_path('aggregator/categories/1');
$result = menu_execute_active_handler();
$_GET['q'] = $q;

I know I could also perform a DB Query. I am using the "Text Example Code" by the way as shown below:

<script type="text/javascript">

function yourcarousel_initCallback(carousel, state)
{
    // Lock until all items are loaded. That prevents jCarousel from
    // setup correctly and we have to do that in the ajax callback
    // function with carousel.setup().
    // We're doing that because we don't know the exact height of each
    // items until they are added to the list.
    carousel.lock();

    jQuery.get(
        'special_textscroller.php',
        {   
            'feed': 'http://mysite/rss.xml'
        },
        function(xml) {
            yourcarousel_itemAddCallback(carousel, xml);
        },
        'xml'
    );
};

function yourcarousel_itemAddCallback(carousel, xml)
{
    var $items = jQuery('item', xml);

    $items.each(function(i) {
        carousel.add(i + 1, yourcarousel_getItemHTML(this));
    });

    carousel.size($items.size());

    // Unlock and setup.
    carousel.unlock();
    carousel.setup();
};

/**
 * Item html creation helper.
 */
function yourcarousel_getItemHTML(item)
{
    return '<h3><a href="'+$('link', item).text()+'">'+$('title', item).text()+'</a></h3><p>'+yourcarousel_truncate($('description', item).text(), 90)+'</p>';
};

/**
 * Utility function for truncating a string without breaking words.
 */
function yourcarousel_truncate(str, length, suffix) {
    if (str.length <= length) {
        return str;
    }

    if (suffix == undefined) {
        suffix = '...';
    }

    return str.substr(0, length).replace(/\s+?(\S+)?$/g, '') + suffix;
};

jQuery(document).ready(function() {
    /**
     * We show a simple loading indicator
     * using the jQuery ajax events
     */
    jQuery().ajaxStart(function() {
        jQuery(".jcarousel-clip-vertical").addClass('loading');
    });

    jQuery().ajaxStop(function() {
        jQuery(".jcarousel-clip-vertical").removeClass('loading');
    });

    jQuery('#yourcarousel').jcarousel({
        vertical: true,
        size: 0,
        initCallback: yourcarousel_initCallback
    });
});

</script>

Anyway, I have the feed in HTML format, I know I need to run through the items using initCallback and itemAddCallback, but just cannot figure it out. Any help would be appreciated.

Regards,
Nick

wim leers’s picture

Status: Active » Fixed

You may want to ask that in the jCarousel mailing list.

nickbits’s picture

Thanks Wim, will do.

Nick

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

nickbits’s picture

Hi All,

I still have not managed to get a working solution so have simplified the issue. I am trying to obtain a frontpage where I can have content automatically scrolling. I have the frontpage set-up in regions, but ignore that for a minute. I have got the following modules installed:

- Views
- Panels
- jCarousel
- Carousel Panel Style

and all the additional requirements. I have used mini panels to create a panel that uses the Carousel to display data. Lets say that I have a view the 10 most recent blog entries (or any other view). I would like to use the Carousel Mini Panel to display each blog entry individually, one at a time and then autoscroll (manual would do to start with) to the next entry. I must be having a dense time at the moment as I simply cannot get this to work. I have deleted what I have done and am starting again!

I know I need to pass arguments but am going around in circles. I would very much appreaciate any suggestions on how I could accomplish this. I am not sure if this is an issue with the Carousel module, the Views, or more likely, me not understanding.

Regards,
Nick