Create custom block on front-end module in magento

Note:- you can download code from this rar_image
Note:-1) Firstly Disable the all cache from Cache Management tab in System tab.
2) select the default theme of the magento from the System->Design.

Step1:- Create Mywork_Useblock.xml file in app/etc/modules/.
where Mywork is Namespace and Useblock is Modulename.

<?xml version="1.0"?>
<config>
    <modules>
        <Mywork_Useblock>
            <active>true</active>
            <codePool>local</codePool>
        </Mywork_Useblock>
    </modules>
</config>

Note:- 1) If you want to active the extensions then use true otherwise false.
2) there are three code pool (a) local (b) core (c) community
when we create the own extension then we use local code pool.

Step2:- Now create the config.xml file in app/code/local/Mywork/Useblock/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mywork_Useblock>
            <version>1.0.0</version>
        </Mywork_Useblock>
    </modules>

    <frontend>
        <routers>
            <useblock>
                <use>standard</use>
                <args>
                    <module>Mywork_Useblock</module>
                    <frontName>useblock</frontName>
                </args>
            </useblock>
        </routers>
        
        <layout>
            <updates>
                <useblock>
                    <file>useblock.xml</file>
                </useblock>
            </updates>
        </layout>
   </frontend>	
  
  <global>
      <blocks>
            <useblock>
                <class>Mywork_Useblock_Block</class>
            </useblock>
        </blocks>
    </global>
  </config>

Note:- 1) In this file we created version of this module is 1.0.0
2) In the frontend tag we created routers tag. In routers tag we define the frontend name is useblock,
and we access the extension value from siteurl/useblock.

Step3:- Now we create the IndexController.php in app/code/local/Mywork/Useblock/controllers/IndexController.php

<?php
class Mywork_Useblock_IndexController extends Mage_Core_Controller_Front_Action {

    public function indexAction() {
    		
    	$this->loadlayout();
        $this->renderlayout();
    }
    
}
?>

Step4:- Now create the Useblock.php in app/code/local/Mywork/Useblock/Block/Useblock.php

<?php
class Mywork_Useblock_Block_Useblock extends Mage_Core_Block_Template
{
	
    public function _prepareLayout()
    {
    	
		return parent::_prepareLayout();
    }
    
    public function get_myname()
    {
		return 'John';
    }
}

Step5:- Now create the useblock.xml in app/design/frontend/default/default/layout/useblock.xml

<?xml version="1.0"?>
<layout version="1.0">
   <useblock_index_index>
		<reference name="content">
            <block type="useblock/useblock" name="useblock" template="useblock/useblock.phtml" />
        </reference>
    </useblock_index_index>
</layout>

Step6:- Now create the useblock.phtml in app/design/frontend/default/default/template/useblock/useblock.phtml

<?php
$myname=$this->get_myname();
echo 'Hello friend'.$myname;
?>

Note:- call the url
siteurl/useblock Output:- Hello friendJohn