Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » the possibilities in FrontEnd

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: 1057 Views
  • fiord
    Avatar
    Community Member
    79 Posts

    the possibilities in FrontEnd Link to this post

    I have a few questions on opportunities DataObjectManager Module
    I will ask them based on the code given in http://doc.silverstripe.com/doku.php?id=modules:dataobjectmanager

    1. Possible to show one Testimonial item in modal window?
    (let's say I have a TestimonialPage that shows all Testimonials Author with link. When you click on the link opens a modal window (like in the admin part) which shows detailed information about selected author (Date,Author,Quote))

    2. it possible to do paging in frontEnd (like in the admin part) for TestimonialPage?

  • UncleCheese
    Avatar
    4085 Posts

    Re: the possibilities in FrontEnd Link to this post

    There are a number of ways to do this.

    I'm not going to go through and explain how to set up a lightbox. You can use whatever one you want and follow the documentation. But to get the testimonial by ID, you need to set up an action on your controller

    YourTestImonialHolderController extends Page_Controller
    {
    function show()
    {
    if(isset($this->urlParams['ID']) && is_numeric($this->urlParams['ID']) {
    if($testimonial = DataObject::get_by_id("Testimonial",$this->urlParams['ID'])) {
    echo $testimonial->Text;
    }
    }
    }
    }

    And you would access that from /URL-to-your-holder/show/123

    where 123 is the ID of the testimonial you want.

  • fiord
    Avatar
    Community Member
    79 Posts

    Re: the possibilities in FrontEnd Link to this post

    thanks
    it's cool
    I do not believe that it is so easy to obtain

    I have a another question, can I do all the same thing, only without the modal window (in the body of my TestImonialHolder)?

  • UncleCheese
    Avatar
    4085 Posts

    Re: the possibilities in FrontEnd Link to this post

    Yes. This is explained in the Code Examples sticky for showing a resource by category.

    MyTestimonial_Controller extends Page_Controller
    {
    function show()
    {
    $testimonial = DataObject::get_by_id("MyTestimonialObject",$this->urlParams['ID']);
    if($testimonial) {
    return $this->customise(array(
    'Testimonial' => $testimonial
    ));
    }
    return false;
    }
    }

    /my-testimonial-holder/show/123

    MyTestimonialHolder_show.ss
    <% control Testimonial %>
    $Text $Date, etc..
    <% end_control %>

  • fiord
    Avatar
    Community Member
    79 Posts

    Re: the possibilities in FrontEnd Link to this post

    I want to tell, as I realized what I needed. Maybe someone will tell you is the best way?
    How to correctly handle $_GET values in SilverStripe? $this->urlParams not approached.

    And I have yet to be invented how to implement paging

    in my code Tender extends DataObject

    class TenderPage_Controller extends Page_Controller {
       
       function showTenderID(){
          if(isset($_GET['TenderID']) && is_numeric($_GET['TenderID'])) {
             $tenderIt = DataObject::get_by_id("Tender",$_GET['TenderID']);
             return $tenderIt ? $tenderIt : false;
          }else{
             return false;
          }
       }

    }


    in tenderPage template

    <% if showTenderID %>

       <% control showTenderID %>
          <h3><a href="{$Top.Link}?TenderID={$ID}" title="$Name.XML" class="newsH">$Name</a></h3>
          <div class="IntroText">$Description</div>
          .............
       
       <% end_control %>
    <% else %>

       <% if Tenders %>
       <div class="newsList">
       <% control Tenders %>
          <h3><a href="{$Top.Link}?TenderID={$ID}" title="$Name.XML" class="newsH">$Name</a></h3>
          <div class="IntroText">$Description</div>
          ....................
       <% end_control %>
       </div>
       <% end_if %>
       
    <% end_if %>

  • fiord
    Avatar
    Community Member
    79 Posts

    Re: the possibilities in FrontEnd Link to this post

    Thanks UncleCheese
    I did as I know myself because had no time to see your answer
    later I try to alter my code as you showed

    1057 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.