Monday, May 30, 2011

Create Simple Module Prestashop, EN

First, create a folder in the folder modules. For example, create a module allo. Create modules / allo. The files: allo.php, allo.tpl, config.xml, en.php.

Step 1:

Allo.php

<?php

if (!defined('_CAN_LOAD_FILES_'))
exit;

define('BLOCKTAGS_MAX_LEVEL', 3);

class Allo extends Module
{
function __construct()
{
$this->name = 'allo';
$this->tab = 'front_office_features';
$this->version = 1.0;
$this->author = 'My Name';

parent::__construct();

$this->displayName = $this->l('Allo');
$this->description = $this->l('Olla Allo.');
}


function hookLeftColumn($params)
{

return $this->display(__FILE__, 'allo.tpl');

}

}

Step 2:

Allo.tpl

<div id="allo_block_left" class="block allo_block">
<h4>{l s='Allo' mod='allo'}</h4>
<p class="block_content">
<font color=””>Contact Us</font>
<br>
<font color=””>Write it all in here
</font>

</p>


</div>


Step 3 :

Config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>allo</name>
<displayName>Allo</displayName>
<version>1</version>
<description>Olla Allo.</description>
<author>PrestaShop</author>
<tab>front_office_features</tab>
<is_configurable>0</is_configurable>
<need_instance>1</need_instance>
</module>


Step 4:

En.php
<?php

global $_MODULE;
$_MODULE = array();




Step 5:

in addition to the above files, create a css file for it. In the folder themes_name/ css / allo. Files allo.css...


/* Allo */
div.allo_block .alo_content { padding: 3px 6px 0 }
div.allo_block p {
text-align: justify;
font-size: 0.9em
}
div.allo_block p a {
margin: 0 0.1em;
line-height: 1.5em
}
div.allo_block p a:hover {
color: white!important;
background-color: #5D717E;
text-decoration: none
}
a.allo_level3 { font-size: 1.8em; font-weight: bold }
a.allo_level2 { font-size: 1.4em }
a.allo_level1 { font-size: 1em; color: #888!important }

activated the module from the backend first.

Step 6:

Going to the administrator area, tabs module, search module allo. If there are click enabled. If not, going to phpmyadmin, to bring the module to module list. Select the table _module, search exist or not allo. If not, insert new fields, with names allo, active field contents with 1. and then, go to admin, enable the module.

Pada frontend, klik refresh apa ada module allo?. Kalo tidak ada, halaman admin - tab preference, klik perfomance, pada Smarty.... Force compile ganti yes. coba di frontend, sudah muncul? Kalo belum pada backend cachenya kita ganti no. refresh lagi, sudah muncul? Kalo sudah muncul, ke admin lagi, kita ubah ke default semula force compile dan cache. fungsinya merubah force compile untuk mengcompile ulang prestashop. Kalo force compilenya no, akan mengcompile dari smarty-nya. Kalo yes, akan decompile semuanya (dari file-file tpl yang baru dibuat). Makanya waktu ngerefresh lumayan berat.

On the frontend, click refresh, module allo appears?. If not available, admin pages - preference tab, click Perfomance, on Smarty .... Force compile replace yes. Trying on the frontend, it appears? If not yet in its cache backend we replace the no. refresh again, it appears? If it appears, to the admin again, we change it to default compile and cache the original force. to change force its function re-compile to compile prestashop. If force compile is no, will compile from his smarty. If yes, will decompile all of them (from the tpl files newly created). So then to refresh, is slow.


to display something of writing in the module and can be in the link. To display a word use the function like this: {ls = 'Halooo .... hehehehe. '}. Create a file in the root folder allo.php


Step 7:

Allo.php

<?php
$task=$_GET['task'];

include(dirname(__FILE__).'/config/config.inc.php');

if (Tools::getValue('ajaxSearch') AND $query = urldecode(Tools::getValue('q')) AND !is_array($query))
{
include(dirname(__FILE__).'/init.php');
$link = new Link();
$search = Search::find(intval(Tools::getValue('id_lang')), $query, 1, 10, 'position', 'desc', true);
foreach ($search as $product)
echo $product['id_product'].'|'.$product['pname'].'|'.$product['cname'].'|'.$link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite'])."n";
die;
}

include(dirname(__FILE__).'/header.php');
include(dirname(__FILE__).'/product-sort.php');

if ($task=='one')
{
echo"This number one
<br><br>
Module:<br>
";
$a1=mysql_query("select *from ps_module limit 10");
while($a=mysql_fetch_array($a1))
{
echo"$a[name]<hr>";
}

}

else
{
echo"what your choice?";
}

include(dirname(__FILE__).'/footer.php');

?>


In row if ($ task = 'one'). if click the link to one on the module will display on if ($ task = one), if you want add other functions means that if ($ task = two), etc ....

0 komentar:

Post a Comment

Thanks a lot for your attention...

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Best Web Hosting