Skip to main content

OpenCart : Create a Controller

To make a cotorller
class Controller<foldername><filename with out extention> extends Controller{
   public function index(){
    .....
    }
   public function showlist(){
    .....
    } 

The there will be no space in the class name and it should extend the controller class.

This controller can be called by example.com/index?route=foldername/filename
The file name should not include extension  . The method index will call automatically and it should be public .  We can access the method showlist by the link example.com/index?route=foldername/filename/showlist the method showlist should me public .

Comments

  1. Bonuses and Games at Casinosites.One of the Best Casino Sites for
    Bonuses and Games at Casinosites. One of 골든 리치 the Best Casino Sites for Playing Slots Online - See all Casinosites reviews, 해외 토토 사이트 all posted by one or more users. 바카라 검증사이트 Rating: 스포츠 토토 5 · ‎Review by Casino 바카라 사이트 Sites

    ReplyDelete

Post a Comment

Popular posts from this blog

OpenCart : Route

In open cart the routeing technique is very simple, If we wan  to call a module or controller /catalog/controller/product/category.php the we have to call it like 'index.php?route=product/product'. Here product is the folder name category is the controller file name without the file extension.   'index.php?route=product/product'  it will execute the   public function index(){     ...  }  'index.php?route=product/product/menthod' then is ill call    public function method(){     ...  } the method should be public otherwise the system will not be able to call it we will know more about that later.

Mysql function: GROUP_CONCAT() (Like implode() in php)

Today i have to solve a problem in MySql , The problem is i have two table in openCart 1. category_description category_id language name 1 1 category 1 2 1 category 2 3 1 category 3 4 1 category 4 5 1 category 5 6 1 category 6 7 1 category 7 8 1 category 8 1. product_category produc_id category_id 1 1 1 2 1 5 2 1 2 3 2 4 3 2 3 6 The resulting data should be like that produc_id category_name 1 category 1,category 2,category 5 2 category 1,category 3,category 4 3 category 2,category 6 I can do tha by in php by taking the category name to it's respective product id and implode them , but it will take much time and processor power cos the i have to do query every product id separately, I was searching the right query in MySql and found the function   GROUP_CONCAT()  http://dev.mysql.com/doc/refman/5.0/en/gr...

PHP : Creating a CSV file as download file from array

Few days earlier I need to Create a text Or SCV file what will return some of the datafeed. Condition is i can't save the file in the serve i have to create and make to download for the user. So i made the below function   function genarateFeedTextFile($data=array(),$file_name=''){ $text=''; $temp=array(); if($data){ foreach($data as $value){          $text .= implode("\t",$value)."\n"; } } header("Content-Type: text/plain"); header("Content-disposition: attachment; filename=".$file_name.".txt");  header("Content-Transfer-Encoding: binary");  header("Pragma: no-cache");  header("Expires: 0"); echo $text; } This function solved my problem. But soon i have a little more problem. Some of my data contain new line "\n" or "\r" to tab "\b" so the result was not expected so i made a new function and puss all the string...