Hi Guys,
I am hoping someone can help me, because I'm going nuts right now. I am trying to create a section on the home page that shows files that have been uploaded to specific pages. I run through the three tables I am using to house the information, and I create a $html variable that I then pass to the template. The template, in theory, would simply run the HTML and problem is solved. However it appears as though the template file is escaping the HTML automatically and when I view the source I see:
<dt>Public Works & Enviromental Services </dt><dd><a href="assets/Uploads/Metro-CollaborateProduct-Brochure.pdf">Metro CollaborateProduct Brochure</a></dd>
I am new to Silverstripe, as I am used to building custom systems so I've been struggling with some of the logic/reasoning behind why certain things work certain ways.
Here is my code:
Template:
<% control Resources %>
$html
<% end_control %>
Here is the function being used:
function Resources()
{
$resource = DataObject::get("SiteTree", "ClassName = 'ResourcePage'");
$html = '';
foreach ($resource as $docData)
{
$html .= '<dt>'.$docData->Title.'</dt>';
$fileListing = DataObject::get("Resource", "ResourcePageID = $docData->ID");
foreach ($fileListing as $singleFileList) {
$files = DataObject::get("File", "ID = $singleFileList->AttachmentID");
foreach ($files as $single)
{
$html .= '<dd><a href="'.$single->FileName.'">'.$single->Title.'</a></dd>';
}
}
}
return $html;
}
Any help with this would be great as I'm going crazy trying to understand what's happening.