I am new to this forum and as well as to OpenCart.
I need help on creating a module in OpenCart. In my case it will get the latest 5 posts from each category of my WordPress installation and display it in my home page of my OpenCart store.
I have already installed OpenCart and WordPress in same database on the same host.
Can someone advice me on this?
Thank you TheBlankBenzKid for a very helpful answer, but I think there is one small thing worth adding here. If you do wish to display your wordpress blogs on your opencart shop, make sure you give your wordpress databases the correct user permissions to the opencart database user, done im my case via cpanel.
This can be very easy depending on your skills. I expect a downvote on your question but I will briefly run through the steps since this is not the way SO works. The first thing is to edit our THEMES files. Since OpenCart is MVC, we edit our Theme and then our PHP... or PHP and then the THEME files.. this is vice versa..
Guide
1 - Open
/catalog/view/theme/default/template/common/home.tpl
After this line:
Add this:
or this:
2 - Open our PHP code which is now the code for the
home.tpl
page, this is/catalog/controller/common/home.php
At the bottom of the code after the main class and the ending
?>
PHP tag add this:That should give you an idea of some basic PHP function calls. It is a direction to get you started. You can further expand to link categories, author links, etc..
By the way, all these variables can be used as you can see in the WP_Posts table:
Tips
Generally look through the entire OpenCart filter on SO - there are many articles on writing mods, modifying how it works and creating custom pages - these will really help in your long time tweaking. The above code is not got styling or further tweaks, this is a guide.
Further reading and better module type posts
How to add new module to opencart administration?
How to add new module to opencart administration?
How to create a custom admin page in opencart?
How to create a custom admin page in opencart?
How do I get an external page coupon/voucher form to work in OpenCart?
How do I get an external page coupon/voucher form to work in OpenCart?
Opencart - How I can execute a custom code on product page? Without mods on controller product
Opencart - How I can execute a custom code on product page? Without mods on controller product
How can I display the SubTotal on OpenCart on any page?
How can I display the SubTotal on OpenCart on any page?