Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

the possibilities in FrontEnd


Reply


6 Posts   1136 Views

Avatar
WebSpilka

Community Member, 83 Posts

16 October 2009 at 10:02am

Edited: 16/10/2009 10:03am

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

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?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

17 October 2009 at 1:39am

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.

Avatar
WebSpilka

Community Member, 83 Posts

18 October 2009 at 9:32am

Edited: 18/10/2009 9:34am

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)?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

18 October 2009 at 10:35am

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 %>

Avatar
WebSpilka

Community Member, 83 Posts

18 October 2009 at 10:38am

Edited: 18/10/2009 10:41am

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 %>

Avatar
WebSpilka

Community Member, 83 Posts

18 October 2009 at 10:46am

Edited: 18/10/2009 10:50am

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