21295 Posts in 5734 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 198 Views |
-
control inside control

13 October 2011 at 1:10am
Hello all,
I'm struggling with the following:
I have a sidebar widget that needs to show certain items. These items, however, contain a reference ID to another table in the database with the item's content. How can I get the template to render this information, like:
Item 1
- Content 1
- Content 2
Item 2
- Content ...
.
.
.I can (probably) only access the content through a DataObject::get() call. In the template, I suggest I need something like:
<% control getItems %>
$Name
<% control getContent %>
$Name
<% end_control %>
<% end_control %>Any help would be highly appreceated.
Friendly regards,
Maurice -
Re: control inside control

15 October 2011 at 8:46pm
These items, however, contain a reference ID to another table in the database with the item's content.
How are these two objects related? If you're using a has_one relationship then you can simply use the ORM in the template. Also to get the items you need to use DataObject::get('ClassName') to get all the items of your ClassName.
// SomeClassName.php has something like
static $has_one = array('Content' => 'Page');// in your widget PHP
function getItems() {
return DataObject::get("SomeClassName");
}// in your widget template
<% control Items %>
<% control Content %>
$Title... $MenuTitle
<% end_control %>
<% end_control %>
| 198 Views | ||
|
Page:
1
|
Go to Top |


