Monday, August 4, 2014

Magento custom module with custom database table admin page

Below Code is simple method to view your custom table datas in admin panel
Admin view for your custom module :

Create the below path in your module :

/app/code/local/<Namespace>/<Module>/etc/adminhtml.xml

in adminhtml.xml file contain below content

<?xml version="1.0"?>
<config>
    <menu>
        <[module] module="[module]">
            <title>[Module]</title>
            <sort_order>71</sort_order>               
            <children>
                <items module="[module]">
                    <title>Manage Items</title>
                    <sort_order>0</sort_order>
                    <action>[module]/adminhtml_[module]</action>
                </items>
            </children>
        </[module]>
    </menu>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <[module]>
                        <title>[Module] Module</title>
                        <sort_order>200</sort_order>
                    </[module]>
                </children>
            </admin>
        </resources>   
    </acl>
    <layout>
        <updates>
 
Create the Adminhtml folder and create Controller.php file 

/app/code/local/<Namespace>/<Module>/controllers/Adminhtml/<Module>Controller.php

in <Module>Controller.php file contain below content

<?php 
class <Namespace>_<module>_Adminhtml_<module>Controller extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
            $this->loadLayout()->_setActiveMenu('<module>/items');
            $this->renderLayout();

    }   

}
 
app/design/adminhtml/default/default/layout/.xml

in <module>.xml file contain below content

<?xml version="1.0"?>
<layout version="0.1.0">
    <[module]_adminhtml_[module]_index>
        <reference name="content">
            <block type="core/template" name="domain" template="[module]/[module].phtml"/>
        </reference>
    </[module]_adminhtml_[module]_index>
</layout>
 
Create the new folder in below path 

app/design/adminhtml/default/default/template/<module>/<module>.phtml
 
in <module>.phtml file contain below content

<?php

// Write your custom table Collection Here

?>

Friday, August 1, 2014

Anchor Clickable Background image in PHP, CSS

In my website, I wants to display the background image with 100% width and provide link to another website when we click the background image.

<style type="text/css">    
    #header_img a.block_link {
        display: block;
        position: absolute;
        margin:auto;
        z-index:0;
        height: 1024px;
        width: 100%;
        background-position:center top;
    }
</style>


<div id="header_img" class="header_img block block2" style="margin: 0 auto; width:100%; background-image:url(images/bgimage.jpg); background-repeat:no-repeat; background-position:center top">
    <a href="welcome.php" class="block_link" target="_blank"></a>

<div id="header_vdo" class="header_vdo" style="text-align:center; width: 100%; height:300px; margin: 0 auto; z-index:1; padding: 1px 0px 1px 0px">
Welcome to Test Page
</div>

</div>