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

pb with dataobjectmanager testimonial example


Go to End
Reply


39 Posts   3956 Views

Avatar
servalman

Community Member, 211 Posts

22 June 2010 at 4:29am

Hello

I'm trying to use dataobjectmanager so I tried to folow the example provided in :

http://doc.silverstripe.org/modules:dataobjectmanager

It works ok as far as creating page type (I get the user interface page as shown).

Now it seems that I don't get something regarding the template and my question is what should be its name (Testimonials or TestimonialPage ?) and what is the the variable(s) I should put in it:
$Testimonials or $Testimonial .

Everytime I try to see it on the draft site I get :

ModelAsController::getNestedController() returned bad object type 'TestimonialPage'

& also this :

Source

61       }
62       
63       try {
64          $result = $this->getNestedController();
65          
66          if($result instanceof RequestHandler) {
67             $result = $result->handleRequest($this->request);
68          } else if(!($result instanceof SS_HTTPResponse)) {
69             user_error("ModelAsController::getNestedController() returned bad object type '" .
70                get_class($result)."'", E_USER_WARNING);
71          }
72       } catch(SS_HTTPResponse_Exception $responseException) {
73          $result = $responseException->getResponse();
74       }
75       
76       $this->popCurrent();

Trace

* ModelAsController::getNestedController() returned bad object type 'TestimonialPage'
Line 70 of ModelAsController.php
* ModelAsController->handleRequest(SS_HTTPRequest)
Line 283 of Director.php
* Director::handleRequest(SS_HTTPRequest,Session)
Line 127 of Director.php
* Director::direct(/new-testimonialpage-2/)
Line 127 of main.php

I have to say I'm lost as I'm not a 'pro' develloper

(if someone can provide me the Testimonial template it would be a great help for me to understand)

Thanks a lot if someone can help me finish the example

T

Avatar
UncleCheese

Forum Moderator, 4096 Posts

22 June 2010 at 7:09am

Templates are always named after the page type that controls them, so in this case you want TestimonialsPage.ss in your templates/Layout dir.

To loop through all the records associated with that page, use a control block:

<% control Testimonials %>
$SomeField $AnotherField
<% end_control %>

Avatar
servalman

Community Member, 211 Posts

22 June 2010 at 11:35pm

Thank you that helped very much and it is now workin .

I have another question tough :

I'm now trying to make kind of Testimonial menu like :

testitmonial 1 - testitmonial 2 - testitmonial 3 etc..

I tried to doit by using :

<% control Testimonials %>
$Testimonials
<% end_control %>

It gives me something like : #1 - #2 - #3 but the links are all leading to home page.

Is there a way to achieve this?

Doest it have something to do with the TestimonialsPage_Controler

Thanks for pointing the direction

Thomas

Avatar
UncleCheese

Forum Moderator, 4096 Posts

23 June 2010 at 1:51am

No, you're already in the testimonials control. Within that, you should be referring to fields on the Testimonials record. Think about it.. if you just say $Testimonials, how is the template supposed to know how you want to present all of those records? Which fields on each Testimonial record do you want to show, and in what kind of HTML structure?

You should read up on dataobject relationship managment in the docs, tutorial #5. That should get you squared away.

Avatar
servalman

Community Member, 211 Posts

23 June 2010 at 3:05am

Thank you

I started to give a look to this tutorial, but I think it is a bit hard for me because it is not showing the :

Project_Controller extends Page_Controller{
}

I wish the dataobjectmanager testimonial example would show how it works to do what I want because I think it is very commun.

I will try tough and let you know how it goes from what I see I think I have to build up 2 controlers.

If I can undertand it I will make a very simple tutorial about that.

Thanks anyway

Avatar
servalman

Community Member, 211 Posts

23 June 2010 at 6:45am

Dear Uncle cheese

I've been trying to achieve what I want but I'm still stuck with this 'upper menu' thing.

Evrything I read seems very unclear .

Could you please be more specific about the controler I have to create to do it

My project is now stuck by that and that other flash thing I posted .

I'm quite desperate since it is now a hours I'm trying to do this.

thanks

Thomas

Avatar
UncleCheese

Forum Moderator, 4096 Posts

23 June 2010 at 8:41am

Edited: 23/06/2010 8:42am

Préférais-tu continuer en français?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

23 June 2010 at 8:43am

C'est juste que je le trouve difficile de te comprendre..

Go to Top