Creating CMS behind existing site


#1

Hii there,

I’m trying to create my own custom blog site (I currently use WordPress, but I’m not a big fan of it).
For this, I have created the site in the way that visitors will see it (main page, blog page, contact page etc.).
Now I want to build a CMS so I can actually add, remove and edit posts.
For this, I want to use a separate layout.

So my question is, how would I go about this?
I want everything that does not start with /admin (eg. https://localhost:8080/contact) to go the “main” site, and everything that does start with /admin (eg. https://localhost:8080/admin/post/edit?post=1234) to go to the cms section of the site (basically, just like WordPress)


#2

its route prefix:
https://book.cakephp.org/3.0/en/development/routing.html#prefix-routing


#3

That does give me a good thing to look at.
But is there also a way to keep my “public” controllers and my “cms” controllers seperate?


#4

Hopefully it will Help you

/**

  • Here, we are connecting ‘/’ (base path) to controller called ‘Pages’,
  • its action called ‘display’, and we pass a param to select the view file
  • to use (in this case, /app/View/Pages/home.ctp)…
    /
    Router::connect(’/admin’, array(‘controller’ => ‘admins’, ‘action’ => ‘login’, ‘prefix’=>‘admin’, ‘admin’ => true));
    Router::connect(’/’, array(‘controller’ => ‘users’, ‘action’ => ‘index’));
    //Router::connect(’/users/login’, array(‘controller’ => ‘users’, ‘action’ => ‘index’));
    /
    *
  • …and connect the rest of ‘Pages’ controller’s URLs.
    */

/**

  • Load all plugin routes. See the CakePlugin documentation on
  • how to customize the loading of plugin routes.
    */

Router::connect(’/faq/’, array(‘controller’ => ‘faqs’, ‘action’ =>‘view_faq’));
Router::connect(’/order/
’, array(‘controller’ => ‘orders’, ‘action’ =>‘index’));
Router::connect(’/contact-us/’, array(‘controller’ => ‘cms’, ‘action’ =>‘contactUs’));
/Rewriting all Cms from database
******/
App::import(‘Model’,‘Cms’);
$cms_seo = new Cms();
$blnk = ‘’;
$cms_seo = $cms_seo->find(“all”,array(‘fields’=>array(‘Cms.id’,‘Cms.seo_keyword’),‘conditions’=>array(‘not’ => array(‘Cms.seo_keyword’ => ‘’))));
foreach($cms_seo as $cms_sub_seo)
{
Router::connect(’/’.$cms_sub_seo[‘Cms’][‘seo_keyword’].’/’, array(‘controller’ => ‘cms’, ‘action’ =>‘view’,$cms_sub_seo[‘Cms’][‘id’]));
}
/Rewriting all Cms from database
******/

CakePlugin::routes();

/**

  • Load the CakePHP default routes. Only remove this if you do not want to use
  • the built-in default routes.
    */
    require CAKE . ‘Config’ . DS . ‘routes.php’;

#5

Damn that’s a lot of code to read :slight_smile:
Thanks, I’ll look into it tomorrow!


#6

you welcome I am always there to Help you if there will be something where i can help you. :sunglasses:


#7

There is also a CakePHP based CMS that you could use: https://github.com/croogo/croogo


#8

I’ve seen that one come along before :slight_smile:
However, since I want to learn CakePHP as well, making it myself feels more rewarding and gives me more value in the long run.
Thanks for sharing it anyways, maybe somebody who comes along here later might want to use it :slight_smile: