I have taken a site to do maintenance and it is in CakePHP
(framework that does not work). It makes some routes for all files that are inside the view/pages
routes.php
foreach(scandir('../View/Pages') as $path){
if (is_dir('../View/Pages/' . $path)) {
foreach(scandir('../View/Pages/' . $path) as $subPath){
if(pathinfo($subPath, PATHINFO_EXTENSION) == "ctp"){
$name = pathinfo($subPath, PATHINFO_FILENAME);
Router::connect('/' . $path . '/' .$name, array('controller' => 'pages', 'action' => 'display', $path . '/' . $name));
}
}
} else {
if(pathinfo($path, PATHINFO_EXTENSION) == "ctp"){
$name = pathinfo($path, PATHINFO_FILENAME);
Router::connect('/'.$name, array('controller' => 'pages', 'action' => 'display', $name));
}
}
}
The page is usually accessible, but they have sent a change to make where the one-page logo (upcreditos.ctp) will be different from the other pages. The problem starts because the site puts the same top, navbar and footer for the pages and only changes the middle. Since I do not know how CakePHP
works then I do not know how to create a custom header.ctp
and just put it to run on the upcreditos.ctp page. I'll put the controller pages below for you to see how it is:
PagesController.php
<?php
App::uses('AppController', 'Controller');
class PagesController extends AppController {
public $uses = array();
public function display() {
$path = func_get_args();
$count = count($path);
if (!$count) {
return $this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count - 1]);
}
$this->set(compact('page', 'subpage', 'title_for_layout'));
try {
$this->render(implode('/', $path));
} catch (MissingViewException $e) {
if (Configure::read('debug')) {
throw $e;
}
throw new NotFoundException();
}
}
public function admin_display() {
$path = func_get_args();
$count = count($path);
if (!$count) {
return $this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count - 1]);
}
$this->set(compact('page', 'subpage', 'title_for_layout'));
try {
$this->render(implode('/', $path));
} catch (MissingViewException $e) {
if (Configure::read('debug')) {
throw $e;
}
throw new NotFoundException();
}
}
}
I need a light to know how to change only the top. If you need me to post a controller, model or view here, just ask, because I do not know what you need to resolve this change.