How to create a custom page in OpenCart

Create custom page in OpenCart

Going to discuss about how to create custom page in opencart. Actually Opencart is built from MVC (Model View Controller).Opencart works on the flow of MVC.So, to create a custom page we must follow MVC pattern.
M – Model -Load Model for query with database tables.
V –View – View is a template file for front end to display a page view.
C – Controller – Controller is a file which control all other part like model, view and language and loads in itself.
L – Language –Load Language file which contains text variable statically.
Follow these steps:
1) Go to catalog/controller and create a file like sellerpage/benefits.php and save it.

<?php  
class ControllerSellerpageBenefits extends Controller {
  public function index() {
    // set title of the page
    $this->document->setTitle("Benefits");
    
    // define template file
    if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/sellerpage/benefits.tpl ')) {
      $this->template = $this->config->get('config_template') . '/template/sellerpage/benefits.tpl';
    } else {
      $this->template = 'default/template/sellerpage/benefits.tpl ';
    }
    
    // define children templates
    $this->children = array(
      'common/column_left',
      'common/column_right',
      'common/content_top',
      'common/content_bottom',
      'common/footer',
      'common/header'
    );
    
    // set data to the variable
    $this->data['my_custom_text'] = "This is my Seller custom page.";

    // call the "View" to render the output
    $this->response->setOutput($this->render());
  }
}
?>

2) Controller keyword following name of directory like “Sellerpage”.
Now Go to create a template file which is loading in controller file for front-end layout of this page. Let prepare the view for page.

<?php 
    echo $header;
    echo $column_left;
    echo $column_right; ?>
    <div id="content">
        <?php 
            echo  $content_top;
            echo  $my_custom_text;
            echo  $content_bottom;
        ?>
    </div>
<?php echo $footer; ?>

Your Custom page is created successfully in OpenCart ,to access this page just go to URL like http://www.yoursiteurl.com/index.php?route=sellerpage/benefits.