Jump to content

Adding msqli to custom PHP page


Recommended Posts

I have been creating a simple blog page for my Prestashop website. SO far I have been able to create the following files and the template is displaying correctly.

BlogController.php (located at /controllers/front directory)

    class BlogControllerCore extends FrontController
      public $php_self = 'blog.php';
      public function setMedia()
      public function displayContent()

blog.php (located at root directory)


blog.tpl (located at theme directory)

    {capture name=path}{l s='Blog'}{/capture}
    <h1>{l s='Blog posts'}</h1>

My question is, how can I add some mysql queries (select, show) into the pages and display my blog posts (using a while loop maybe?) in the blog page?


I'm on Prestashop version

Edited by ystar (see edit history)
Link to comment
Share on other sites

Check documentation about DB class and working with database  




also you may want to check for module



Thanks for the reply. I looked into that documentation. I couldn't find any examples which clarifies my issue. May I ask any good source for see some examples?


And about the module, even if the module sounds promising, I cannot use that in my website, since it gives me a white page error without any error messages.

Link to comment
Share on other sites

First I forgot to mention that what you want needs some work.

And that is better way to do it like a module then adding global controller like that, you need a way to add post in back office

also, maybe some blog categories, some rewrite rules in Dispatcher, all similar to CMS structure. If you go to module then 

you need module controller, some classes for blog post example where you will also add functions to retrieve those post from database.


Well check more into documentation and also code from existing modules like



https://github.com/PrestaShop/homeslider  or  smartblog module itself 




If you have that white page for smartblog try to enable debug mode, I remember I once had issues after installing module,

think was example blog posts, - or _ problem. Check https://www.prestashop.com/forums/topic/317230-prestashop-blog-module/ it does have 

a lot of posts but if you ask for help think smartdatasoft usually replay fast.


Or there is also good but paid module https://www.prestashop.com/forums/topic/305917-module-blog-for-prestashop-with-post-types/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...