CakePHP Elements

Reading time ~1 minute

This is a basic tip which comes in handy. Elements allow you to place blocks of code that are repeated or reused in your application. They also come in handy if you are just looking to tidy up that view of yours.

In this example we are going to take our login form and make it an element. Then we will call it on our page. This tip is to show how to add an element, so don't worry if you don't understand the login code. Lets name this file login.ctp and put it in our /App/View/Elements folder.

<?php echo $this->Form->create('User', array('action' => 'login'));
    echo $this->Form->input('email_address',array('label' => '', 'class'=>'span3', 'placeholder' => 'Email Address'));
    echo $this->Form->input('password',array('label' => '', 'class'=>'span3', 'placeholder' => 'password'));
    echo $this->Form->end(array('label' => 'Sign In', 'value' => 'Sign In', 'class' => 'btn btn-primary'));
And in our view file (/App/View/Pages/home.ctp or whatever View you are working on)

<?php echo $this->element('login'); ?>
That's it! You should now have the basics to including an Element in your View! Congratulations! We knew you could do it!>

Asyncio Basics Python 35

# Asyncio basics in pythonPython 3.5 brought with it asyncio. An event loop based paradigm previously available as a library but now it i...… Continue reading

Quick Laravel/Lumen install with Docker!

Published on March 02, 2016

PHP To Python

Published on February 24, 2016