Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    opencart-hyperlocal-marketplace-guide

    Show module data at front layout in Opencart

    In our previous blog, we learned to build a module in the Opencart. Now, we will learn about saving the values in the module configuration and show them in the front end by putting them on some layout (like account page, product page, home page etc).

    So, in order to start, we need to make a module like we did here. Now, I’ve added two more fields to get the heading and description of the content to be shown at the front end.

    I’ve created a language file named ‘side_layout.php’ in admin->language->en-gb->module (Opencart version 2.2.0.0). The code for language file is here:


    Now, I’ve created a file name ‘side_layout.php’ in admin->controller->module (Opencart version 2.2.0.0). Here’s the code for controller file:


    A file is created with the name ‘side_layout.tpl’ in admin->view->template->module. The code for that file is here:


    In order to use this module to show its content in the front, we have to build a controller in catalog->controller->module with the same name as we made in the backend i.e. ‘side_layout.php’.

    Here’s the code for that controller:


    We are using a .tpl file to show the content in the HTML tags. So, we will create a file named ‘side_layout.tpl’ in catalog->view->theme->default->template->module. The code is as here:


    Now, after doing this, we have to set the module on some layout. Here, I’m setting the module on the checkout page. So, for doing that, go to the admin panel and head towards Design->Layouts. From the layouts list, edit the checkout and select the ‘Side Layout’ from the module list and set to your preferred position. I’ve set it on ‘Column Right’ position. See the image.

    This will look like this in the front end on the checkout page. See image.

    Whatever entries/values you will provide in the backend will be visible in the front-end module. Hope, you learned from this. In the case of any query, just comment.

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close