Silverstripe Version:
4
Question:
So i’m having a small bit of trouble using the renderWith(show_message’) and outputting HTML into the template ‘show_message’.
My problem is that the message text doesn’t render the link in the text. It doesn’t seem to parse the <a href as html?
is there anything i did wrong here?
$this->setMessage("Error", "Please go to the <a href=\"profile\"> profile page</a> before continuing");
public function setMessage($type, $message)
{
$request = Controller::curr()->getRequest();
$request->getSession()
->set('Message', array('MessageType' => $type, 'Message' => $message));
}
public function getMessage()
{
$session = $this->getRequest()->getSession();
if ($message = $session->get('Message'))
{
$session->clear('Message');
$messageData = new ArrayData($message);
return $messageData->renderWith('Layout/show_message');
}
}
template…
<% if Message %>
<p class='message' id='{$MessageType}Message'>
$Message
</p>
<% end_if %>
Thanks
Grant