Add a simple slideshow to a page (v. 2.95)

In later 2.9 versions, Site Blocks can be used to create snippets that can then be inserted into other pages. (See Site Blocks.) With a quick modification, you can use these site blocks to create a simple slideshow of images that can then be added to your web site.

  1. Open the popups.php file in the /storeadmin/ folder and make the following changes:

    1. Add the following code:

      // REMOVE SLIDESHOW IF EXISTS
      $popupcontent = str_replace('%BLOCKSLIDESHOW%', '', $popupcontent);
      if ($isslideshow == 'y')
      $popupcontent = '%BLOCKSLIDESHOW%' . "
      " . $popupcontent;

      Just above the line:

      $blockcode = preg_replace("/[^A-Z0-9]+/", "", strtoupper($blockcode));
    2. Add the code:

      $is_slideshow = '';

      just under the code:

      $isblockadmin = 'n';
    3. Add the code:

      $is_slideshow = substr_count($popupcontent, '%BLOCKSLIDESHOW%');
      $popupcontent = str_replace('%BLOCKSLIDESHOW%', '', $popupcontent);

      just below the code:

      $popupcontent = stripslashes($getpgrow['Content']);
    4. Add the code:

      echo " slideshow";

      just above the code:

      if ($set_master_key == "yes")
      {
      echo " admin only";
      }
  2. Open the openinfo.php file in the /enc/ folder and make the following changes:

    1. Find the code

      // BLOCK ARRAY

      around line 566.

    2. Add the following functions just above that code:

      // PARSE BLOCK IMAGE
      function parse_block_image($imagetag, $blocktitle, $idnumber, $idpos=0)
      {
          $imagetag = str_replace("'", '"', $imagetag);
          $imgpieces = explode(' ', str_replace(array(''), '', $imagetag));
          list($src, $title, $alt) = '';
          foreach($imgpieces AS $imgpc)
          {
              $posequal = strpos($imgpc, '=');
              if ($posequal !== false)
              {
                  $attname = substr($imgpc, 0, $posequal);
                  $$attname = str_replace('"', '', substr($imgpc, $posequal+1, strlen($imgpc)));
              }
          }
          if (empty($alt))
              $alt = $blocktitle;
          if (empty($title))
              $title = $alt;
          if (empty($idpos))
              $parsed_img = "$alt";
          else
              $parsed_img = "$alt";
          return $parsed_img;
      }
      
      // CREATE BLOCK SLIDESHOW
      function create_block_slideshow($idval, $content, $blockcode, $blocktitle='Slideshow Image')
      {
          $blockcontent = stripslashes($content);
          if (substr_count($content, '%BLOCKSLIDESHOW%') == 1)
          {
              // extract images
              preg_match_all('/]+>/i', $content, $blockmatches);
              $blockimglist = array();
              // images exist
              if (!empty($blockmatches[0]))
              {
                  $blockimglist = array_values($blockmatches[0]);
                  $blockcontent = '
      ‹
      ›
      ' . parse_block_image($blockimglist[0], $blocktitle, $idval, 0) . '
      '; foreach($blockimglist AS $bkey=>$blocki) { $blockcontent .= parse_block_image($blocki, $blocktitle, $idval, $bkey+1); } $blockcontent .= '
      '; } // automate slide show $automate_blockslide = 5000; if ($automate_blockslide >= 500) { $blockcontent .= ""; } } return $blockcontent; }
    3. Change the 5000 in the line $automate_blockslide = 5000; if you want to speed up or slow down the automation. This value dictates how quickly the next slide will appear. (1000 = 1 second) This value must be at least 500 (1/2 second), and regardless of the value, the automation will stop when you mouse over the image.

    4. In the section under the // BLOCK ARRAY note, change the line

      $blockclist[$blockccode] = $blockcontent;

      to:

      $blockclist[$blockccode] = create_block_slideshow($blockcid, $blockcrow['Content'], $blockccode, stripslashes($blockcrow['PageTitle']));
  3. Save and reload both files.