View Slideshow by default

Author Message

Andy Woods

Wednesday 18 May 2011 3:25:31 am

I have a gallery with images in it.

Is it possible to display the slideshow by default when visiting the page rather than having to click on the 'View as slideshow' link?

Thanks,

Andy

Veronique Jamilloux

Thursday 19 May 2011 2:21:45 am

Hi,

In my home page have a slide show using a javascript :

 // Lister ci-dessous toutes les images qui vont s'afficher

NewImg = new Array (
"images/ble_centre.jpg",
"images/dnoxia_centre.jpg",
"images/riz_centre.jpg",
"images/botrytis_centre.jpg",
"images/mais_centre.jpg",
"images/muscadine_centre.png"
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;

//Time delay between Slides in milliseconds
var delay = 2000;

var lock = false;
var run;

function chgImg(direction) {
    if (document.images) {
        ImgNum = ImgNum + direction;
        if (ImgNum > ImgLength) {
            ImgNum = 0;
        }
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (ImgNum < 0) {
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ImgNum = ImgLength;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; document.slideshow.src = "/design/urgi/" + NewImg[ImgNum];
&nbsp;&nbsp; }
}

function auto() {
&nbsp;&nbsp;&nbsp; if (lock == true) {
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lock = false;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; window.clearInterval(run);
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; else if (lock == false) {
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lock = true;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; run = setInterval("chgImg(1)", delay);
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
}

In my template where I define the <body> tag, I put

&nbsp;<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" {if eq($currentNode.node_id,$Root_Node)}onload="auto();"{/if}>

This is my case, may be it will help you.

Bye

VĂ©ronique

URGI - INRA
Webmaster
Route de Saint Cyr
78000 Versailles

Andy Woods

Thursday 19 May 2011 7:57:20 am

Hi Veronique,

Thanks for your post.

I chose to copy the slideshow code from the ezwebin image.tpl instead and add it to my gallery.tpl.  I just needed to change the fetch statements a little so that the parent node_id wasn't selected.

{def $sort_order=$node.parent.sort_array[0][1]
     $sort_column=$node.parent.sort_array[0][0]
     $sort_column_value=cond( $sort_column|eq( 'published' ), $node.object.published,
                             $sort_column|eq( 'modified' ), $node.object.modified,
                             $sort_column|eq( 'name' ), $node.object.name,
                             $sort_column|eq( 'priority' ), $node.priority,
                             $sort_column|eq( 'modified_subnode' ), $node.modified_subnode,
                             false() ) }
{if $sort_column_value|eq( false() )}
    {set $sort_column_value = $node.object.published
         $sort_column = 'published'}
{/if}
{def
    $previous_image = fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id,
                                                       'class_filter_type', 'include',
                                                       'class_filter_array', array( 'image' ),
                                                       'limit', '1',
                                                       'attribute_filter', array( 'and', array( $sort_column, $sort_order|choose( '>', '<' ), $sort_column_value ) ),
                                                       'sort_by', array( array( $sort_column, $sort_order|not ), array( 'node_id', $sort_order|not ) ) ) )
     $next_image = fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id,
                                                   'class_filter_type', 'include',
                                                   'class_filter_array', array( 'image' ),
                                                   'limit', '2',
                                                   'attribute_filter', array( 'and', array( $sort_column, $sort_order|choose( '<', '>' ), $sort_column_value ) ),
                                                   'sort_by', array( array( $sort_column, $sort_order ), array( 'node_id', $sort_order ) ) ) ) }  
<div class="content-view-full">
    <div class="class-image">
        <div class="attribute-header">
            <h1>{$next_image[0].name|wash()}</h1>
        </div>
        {if is_unset( $versionview_mode )}
        <div class="content-navigator">
            {if $previous_image}
                <div class="content-navigator-previous">
                    <div class="content-navigator-arrow">&laquo; </div><a href={$previous_image[0].url_alias|ezurl} title="{$previous_image[0].name|wash}">{'Previous image'|i18n( 'design/ezwebin/full/image' )}</a>
                </div>
            {else}
                <div class="content-navigator-previous-disabled">
                    <div class="content-navigator-arrow">&laquo; </div>{'Previous image'|i18n( 'design/ezwebin/full/image' )}
                </div>
            {/if}
            {if $previous_image}
                <div class="content-navigator-separator">|</div>
            {else}
                <div class="content-navigator-separator-disabled">|</div>
            {/if}
            {def $parent=$next_image[0].parent}
                <div class="content-navigator-forum-link"><a href={$parent.url_alias|ezurl}>{$parent.name|wash}</a></div>
            {if $next_image[0]}
                <div class="content-navigator-separator">|</div>
            {else}
                <div class="content-navigator-separator-disabled">|</div>
            {/if}
            {if $next_image[1]}
                <div class="content-navigator-next">
                    <a href={$next_image[1].url_alias|ezurl} title="{$next_image[1].name|wash}">{'Next image'|i18n( 'design/ezwebin/full/image' )}</a><div class="content-navigator-arrow"> &raquo;</div>
                </div>
            {else}
                <div class="content-navigator-next-disabled">
                    {'Next image'|i18n( 'design/ezwebin/full/image' )}<div class="content-navigator-arrow"> &raquo;</div>
                </div>
            {/if}
        </div>
        {/if}
        <div class="attribute-image">
            <p>{attribute_view_gui attribute=$next_image[0].data_map.image image_class=imagelarge}</p>
        </div>
        <div class="attribute-caption">
            {attribute_view_gui attribute=$next_image[0].data_map.caption}
        </div>
        {include uri='design:parts/image/related_content.tpl'}
    </div>
</div>

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 01:01:07
Script start
Timing: Jan 18 2025 01:01:07
Module start 'layout'
Timing: Jan 18 2025 01:01:07
Module start 'content'
Timing: Jan 18 2025 01:01:08
Module end 'content'
Timing: Jan 18 2025 01:01:08
Script end

Main resources:

Total runtime1.0895 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 589.0469152.6250
Module start 'layout' 0.00570.0030 741.671939.4531
Module start 'content' 0.00871.0791 781.1250594.2188
Module end 'content' 1.08780.0016 1,375.343824.1641
Script end 1.0895  1,399.5078 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.3638160.0002
Check MTime0.00120.1144160.0001
Mysql Total
Database connection0.00090.080110.0009
Mysqli_queries1.022493.8351570.0179
Looping result0.00060.0544550.0000
Template Total1.054496.820.5272
Template load0.00220.203920.0011
Template processing1.052196.567120.5261
Template load and register function0.00020.015710.0002
states
state_id_array0.00090.085510.0009
state_identifier_array0.00190.174420.0010
Override
Cache load0.00190.1747940.0000
Sytem overhead
Fetch class attribute can translate value0.00070.062020.0003
Fetch class attribute name0.00150.133540.0004
XML
Image XML parsing0.00220.206420.0011
class_abstraction
Instantiating content class attribute0.00000.000740.0000
General
dbfile0.00240.2163160.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs