Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Elements and Layouts in Cakephp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 104
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: