If we are required to Create elements and add it in layouts and views ithe can do it as In app/views/elements folder create an element file adminsidebar.ctp with the below code :
<?php
echo Hello Cakephp !!;
?>
Call the element In the view file or layout file as
<?php echo $this->element('adminsidebar'); ?>
If we want to pass parameters to the elements we can do it with the element() functions as :
<?php echo
$this->element('helpbox',
array("helptext" => "this text ishelpful."));
?>
In the element file, tthe passed variables are available. In the above example, the /app/views/elements/helpbox.ctp file can use the $helptext variable.
<?php
echo $helptext; "
?>
outputs : "this text is helpful"
0 Comment(s)