Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Rotating Banners from specific folder

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1166 Views
  • jparks
    Avatar
    Community Member
    7 Posts

    Rotating Banners from specific folder Link to this post

    After way too many hours of scouring ... I come to the forum for help. This is not a hard request but I simply can't figure it out.

    I installed DOM and SWFUPLOAD and ImageGallery and everything works great. Uncle Cheese rocks!

    I created an album called Banners. The idea is for an individual to access SS CMS and upload a banner that will then automatically be displayed on the homepage. I have the jquery working that rotates the banners and if i drop the absolute url of the pic in there everything works.

    But I can not within my HomePage.php establish the correct query nor the correct control in the HomePage.ss

    What is the best way to display everything that is being dropped into a specific folder "assets/image-gallery/Banners" and have it displayed on the HomePage.

    Thank you for your help.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Rotating Banners from specific folder Link to this post

    public function Banners() {
    $folder = Folder::findOrMake("image-gallery/Banners");
    return DataObject::get("Image", "ParentID = $folder->ID");
    }

  • jparks
    Avatar
    Community Member
    7 Posts

    Re: Rotating Banners from specific folder Link to this post

    Thank you for the quick response ...

    Here is what I have tried ... and I am still missing something because it is not working
    ----------------------
    HomePage.php

    <?php
    /**
    * Defines the HomePage page type
    */

    class HomePage extends Page {
    static $db = array(
    );

    static $has_one = array(
    );

    public function Banners() {
    $folder = Folder::findOrMake("image-gallery/Banners");
    return DataObject::get("Image", "ParentID = $folder->ID");
    }
    }

    class HomePage_Controller extends Page_Controller {

    }
    ?>

    ---------------------------------
    HomePage.ss

    ......
    <body>
    <div id="container">
    <div id="main">
          <div id="wrapper">
             <div id="slider">
             <% control Banners %>
             <img src="$URL" />   
             <% end_control %>      
             </div>
          </div>
    $Content
    </div>
    <div id="right">
    </div>
    </div>
    </body>
    </html>

  • jparks
    Avatar
    Community Member
    7 Posts

    Re: Rotating Banners from specific folder Link to this post

    Thank you Uncle Cheese ... I reviewed my code and everything is working. You got me going in the right direction.

    Muchas Gracias.

    1166 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.