Contact admin pages in cakephp

So, for the simple page used internally, I need to create an admin page, and I want to do this with benefit.

I have one problem with a link to the specified admin pages.

<?php echo $this->Html->link("Blogposts",array('controller'=>'pages','action'=>'home')); ?> <?php echo $this->Html->link("Administration",array('controller'=>'blogposts','action'=>'index','admin'=>true)); ?> 

So: the first link should always go to the main page using blogs. The second link should go to the administration area for the specified blog pages.

It works great. But when I am in the administration area and I click the top link again, it will fail. It will still add the path "/ admin /" to the url.

When I add 'admin' => false to the first link, it works again, but I don't know if this is "best practice" or not.

+4
source share
2 answers

It. Any links in the administration area that you want to go to the area without admin must have 'admin'=>false .

+6
source

If you do not use custom routes, you can also write your links this way:

 <?php echo $this->Html->link("Blogposts",'/pages/home'); ?> <?php echo $this->Html->link("Administration",'/admin/blogposts'); ?> 

But if you want to change the URLs, you can no longer use routes.

+1
source

Source: https://habr.com/ru/post/1402126/


All Articles