Sorry, this page is only available in one language

AutoPlay

Suggested dropletname: AutoPlay

Published by: Dev4me

The AutoPlay Droplet makes it possible to display all pages of your website as a carousel.

This Droplet will make it possible to display all pages of your website as a carousel. To do this the Droplet tag should be included in your template!

$autoplay = "View this site automatically";
$noplay = "Stop automatic view";
if ((int)$timeout == 0) $timeout = 5; 
if (isset($_POST['autoplay'])) {
        if (strcmp($_POST['autoplay'],$autoplay)) unset($_SESSION['autoplay']) ;
        if (strcmp($_POST['autoplay'],$noplay)) $_SESSION['autoplay'] = "1";
}
if (!isset($_SESSION['autoplay'])) {
        return '<form method="post"><input type="submit" name="autoplay" value="'.$autoplay.'"></form>';
} else {
        $page_id = PAGE_ID;
        if ($page_id !== 0) {
                ob_start();     
                show_menu2(0,SM2_ROOT,SM2_ALL,SM2_ALL,',[url]','','','','','');
                $allpages = explode(',', ob_get_contents());
                ob_end_clean();
                ob_start(); 
                show_menu2(0,SM2_ROOT,SM2_ALL,SM2_ALL,',[page_id]','','','','','');
                $allpageids = explode(',', ob_get_contents());
                ob_end_clean();
                $pos = array_search($page_id, $allpageids);
                if ($pos < count($allpageids) - 1) { 
                        $next = $allpages[$pos + 1]; 
                } else {
                        $next = $allpages[1]; 
                }
                $r = '<form method="post"><input type="submit" name="autoplay" value="'.$noplay.'"></form>';
                $r .= "<script>setTimeout("location.href='".$next."'",".$timeout."000)</script>";
                return $r;
        }
        return " ";
}

Optional parameter

timeout=(time_in_seconds_to_display)

Example

[[autoplay?timeout=7]]

 

  • A button for starting and stopping is displayed at the location of the Droplet tag.
  • A parameter (timeout) can be used to change the default 5 seconds timeout before the next page loads.


« Previous droplet | Overview | Next droplet »