23486 Posts in 18995 Topics by 2878 members
|Go to End|
15 March 2011 at 1:50pm
I have a dropdown field in my frontend and want to load special content via ajax after choosing a Kategorie (category)
Requesting via Ajax works fine... but I dont' know how to bring my valus I get with the DataObject::get() method to my template control snippet,..
that's my sql.. it works fine, (i've tested the sql statement in phpmyadmin. It returns several rows of Typ-Table which I connected to the Kategorie (with the ID 6) via an many_many relationship)
$doSet = DataObject::get(
$callerClass = "Kategorie",
$filter = "Kategorie.ID =6",
//$sort = "ORDER BY SortOrder DESC",
$join = "LEFT JOIN Kategorie_Typen ON Kategorie_Typen.KategorieID=Kategorie.ID LEFT JOIN Typ ON Kategorie_Typen.TypID=Typ.ID",
$limit = ""
now id like to get that DataObject rendered with my Typ-Template
to use it in its control-tag
<% control Typ %>
<% end_control %>
something like that..:
this causes two warnings and returns only the empty template:
1. DataObjectSet::__construct:Passed item #0 is not an object or assoziative array, can't properly iterated on in templates
2. Unknown class passed as parameters
How to return my DataObjectSet to my Template and how can I control the data?
Thanks in advance for any advice
16 March 2011 at 6:21pm
Try call renderWith on the controller instance and adding your set to that
return $this->customize(new ArrayData(array('Typ' => $doSet)))->renderWith(array('TypTemplate'));
17 March 2011 at 4:15am
First it caused an error: method customize does not exist on 'Produkte_Controller'
so I tried it without the customize method and that works fine now
$data=new ArrayData(array('Typ' => $doSet));
Thank s a lot !!
|Go to Top|