Hey guys,
My first post here and while I absolutely love the concept behind silverstripe, the learning curve can be a bit tough.
I have a database that looks like this:
`a_letter_template` (`id`, `name`, `letter`, `stamp`, `paper`)
I have a model file called ComposePage.php where I'm running:
$sqlQuery = new SQLQuery();
$sqlQuery->from = array(
"a_letter_template"
);
$result = $sqlQuery->execute();
The result of a var_dump($result->first()) is:
array(5) {
["id"]=> string(1) "1"
["name"]=> string(8) "Serenity"
["letter"]=> string(20) "/letter/letter-1.png"
["stamp"]=> string(19) "/letter/stamp-1.jpg"
["paper"]=> string(19) "/letter/paper-1.jpg"
}
I need to turn this into a data model set that I can use in ComposePage.ss sort of like this:
<% control letters %>
<% include letter1 %>
<% end_control %>
Letter1 is an ss file which contains basic html and needs data from "a_letter_template", e.g.: $name, $letter, $stamp and $paper.
Resume:
I'm trying to output a letter template for each row in a_letter_template (database) by using silverstripe data object as the content insertion mechanic.
I've tried manually creating a letter class, I've tried ArrayLists, I've tried creating a singleton and everything ends up in server errors.
I could export the assoc as a JSON and parse it through KnockoutJS, but that'd be silly since silverstripe handles server side templating so well.