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

Wednesday, January 5, 2022

[FIXED] CakePHP Layout template overriding view template

 January 05, 2022     cakephp, cakephp-3.0, cakephp-routing     No comments   

Issue

I have installed CakePHP 3.8 and my layout template (/src/Template/Layout/default.ctp) is completely overriding my controller view (src/Template/Users/login.ctp).

I have echo'd & die()'d at the beginning/end of both files, so I know they are being called/rendered, but once default.ctp is called/rendered, login.ctp is gone.

I think this a routing issue but I'm not sure. I'm new to install/setup of CakePHP. Any help would be greatly appreciated.


Solution

welcome to StackOverflow. I guess you misunderstood the functionality of the CakePHP templating.

The layout files are supposed to override the view file. In CakePHP when a view renders first the layout is rendered and in that layout, the view is embedded in the place where you use the $this->fetch('content');.

that's the reason why all the dynamic content is placed in the view file and common content like the header and all in the layout.

I hope you got my point.

In case you have still any doubt feel free to ask. I'll be happy to help.



Answered By - Mohd Samgan Khan
  • 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