PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 18, 2022

[FIXED] Creating static home page for CakePHP3

 February 18, 2022     cakephp, cakephp-3.0, model     No comments   

Issue

I am working on a CakePHP3 project. I want a static homepage that will be loaded on www.mysite.com.

For this I have created a PagesController which will handle all the static pages in the website like about,contact,etc.

I am having display.ctp view in Template/Pages/display.ctp to load on www.mysite.com.

But, for testing (routes are not configured yet), I'm using www.mysite.com/pages and www.mysite.com/pages/display to show the view but it gives error as

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mysite.pages' doesn't exist

Do I need to create Table for this ?


Solution

It is much, much easier than that

For this I have created a PagesController

There is already a pages controller for serving static content, and a static template for the home page, there is no need to create/overwrite the default pages controller, to replace it with the same (or less) functionality. This is also mentioned in the documentation

The steps to modify static pages (with default routes) are:

  • edit src/Template/Pages/home.ctp - look at the url /
  • create/edit src/Template/Pages/something.ctp - look at the url /pages/something


Answered By - AD7six
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing