php - CakePHP: HTML in setFlash() -


i'm wondering if there proper way include html in setflash() function of session component.

basically have admin interface on e-commerce website allows administrators create , edit "shops" found on website. upon saving "shop", cakephp display "your shop has been saved. return shop index". "return shop index" link. i'm using plain old html like:

$this->session->setflash("shop has been published. <a href=\"...\">return shop index</a>"); 

works, it's html in controller, think "bad thing".

thanks!

edit:

thanks @yonoran solution. missed out in cakephp documentation. here's did:

1) created new element session_flash_link.ctp in app/views/elements.

2) added following code in session_flash_link.ctp:

<div id="flashmessage" class="message"> <?php echo $message; echo $this->html->link($link_text, $link_url, array("escape" => false)); ?> </div> 

3) code in controller:

$this->session->setflash("shop has been saved. ", "session_flash_link", array(     "link_text" => "return shop management &raquo;",     "link_url" => array(         "controller" => "shops",         "action" => "manage",         "admin" => true     ) )); 

this might solution trying do, loads "layout" html in setflash message. custom cakephp flash message

update:

i checked manual setflash setflash manual

and shows can specify , element holds html setflash message + bunch of other properties.

setflash($message, $element = 'default', $params = array(), $key = 'flash') 

so seems better way of doing whats suggested in first link posted, because doesn't require new layout uses elements.

good luck.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -