0

I've followed the Video store and Jobet examples, and I'm trying to create an Administrator interface in the ./admin subdirectory. However, I want to use templates and I'm not sure if I need to create a new template directory, i.e. ./admin/templates/ or I can use the default template, i.e. ./templates/default/ which is used by the main API ?

Below is the flow of control of the website:

1) /admin/index.php <- instantiates /admin/lib/AdminFrontend

2) /admin/lib/AdminFrontend <- calls /admin/page/index.php (implicitly) for login of admin.

Inside /admin/page/index.php it sets up a login page and calls the defaultTemplate() function:

function defaultTemplate(){
    return array('page/login');
}

However, I get an error "Spot is not found in owner's template".

I've tried to use the addlocation() function inside AdminFrontend to add root template (.template/default/), but I cannot get it to work.

$this->addLocation('../', array( 'template' => array('templates'),
   'php' => 'lib' )
)->setParent($this->pathfinder->base_location);

So the login template is not found, but I'm not sure where atk is looking for the template or how I can change it.

From Roman's post, it seems that any new API's, e.g. admin, need a new template directory for security reasons so no pages/templates are shared between the normal users and admin interfaces.

in ATK4 Can I define a different template from frontend to back end?

Thanks for your advice.

Community
  • 1
  • 1
LostInTheWeb
  • 187
  • 1
  • 11
  • Got it to work by creating the local template directory in the ./admin directory, such that I now have: ./admin/template/default, ./admin/template/default/page, ./admin/template/default/view, etc. – LostInTheWeb Aug 06 '12 at 04:24

1 Answers1

0

Not sure but think you probably wanted to add your subdirectory 'admin' as the first parameter to addLocation something like this

 $this->addLocation('admin',array(
                'page'=>array(
                     'page',
                    ),
                'template'=>array(
                    'templates',
                    ),
                ))
        ->setParent($this->pathfinder->base_location);

Which should then add /admin/templates to the path searched for templates and /admin/page to the paths it searches for pages.

You could also just install the atk4 folders again under a different atkroot which is only used for admin. Depending on your webhost, you could then point a subdomain e.g. admin.yoursite.com at the admin pages but it keeps it completely separate from your user pages but whether this is viable depends on whether you have a lot of common pages, views and models that will be shared between users and admin or whether you are happy to just copy the ones you need to the admin folders.

Trevor North
  • 2,286
  • 1
  • 16
  • 19