I am developing a custom helper and i want that whenever i use this helper, it should load related css/js files in the header section of that particular view..
For example, if i am using "XyzHelper" in "abc" view, XyzHelper should load css/js files in header section of abc view and so on.
Here is my helper code:-
App::uses('AppHelper', 'View/Helper');
class XyzHelper extends AppHelper {
public function show() {
$html = new HtmlHelper(new View());
echo $html->css('custom',array('inline'=>true));
echo $html->script('custom.min',array('inline'=>true));
return "<div style='background-color:rgb(200,0,0);padding:20px;color:white;'>Hello World</div>";
}
}
Above code is loading css/js files but not in the header section of any view.
I have tried append('css') method inside my helper but that also not seems to be working. It says 'append' does not exist.
$this->append('css','<link_to_css_file>');