Jump to content

Editing the Admin Skin [SOLVED]


freshJet

Recommended Posts

About to release my admin skin, however I have been forced to edit the default template files in admin/templates. I noticed that adding them to the skin folder, like you would on the main site, does not work. Changes made to those files in the skin folder do not show up.

Is there a way around this?

Link to comment
Share on other sites

  • Administrators

When the main part of the site was updated to allow skins to automatically check the skin folder and then go to the default if the template is not there, the admin side was not updated. You would need to change the coding in the index file for the admin side mainly to operate like the main site.

Link to comment
Share on other sites

Surprised no one else has gone into this in detail before. It's really annoying.

This is in core/classes/TemplateSet.class.php:

if($force_base === true)
       {
           $old_tpl = $this->template_path;
           $this->template_path = Config::Get('BASE_TEMPLATE_PATH');

           if($checkskin === true)
           {
               if(defined('SKINS_PATH') && file_exists(SKINS_PATH . DS . $tpl_name))
               {
                   $tpl_path = SKINS_PATH . DS . $tpl_name;
               }
               else
               {
                   $tpl_path = $this->template_path . DS . $tpl_name;
               }
           }
       }

       if((!defined('ADMIN_PANEL') || $force_base == true) && $checkskin == true)
       {
           if(defined('SKINS_PATH') && file_exists(SKINS_PATH . DS . $tpl_name))
           {
               $tpl_path = SKINS_PATH . DS . $tpl_name;
           }
           else
           {
               $tpl_path = $this->template_path . DS . $tpl_name;
           }
       }
       else
       {
           $tpl_path = $this->template_path . DS . $tpl_name;
       }

Now obviously this is for the main site as well.

Link to comment
Share on other sites

Solved. Took an entire day, but solved. I've found a solution and it works for me, but please backup core/codon.config.php and core/classes/TemplateSet.class.php.

Open up codon.config.php and scroll down a bit until you see all the define() declarations. Add the following at the bottom:

define('ADMIN_PATH', SITE_ROOT.'admin');

Then, at the end of the file, add:

$admin_skin = Config::Get('ADMIN_SKIN');
define('ADMIN_SKINS_PATH', ADMIN_PATH.DS.'lib'.DS.$admin_skin);

Save your changes and close. Then, navigate to core/classes and open TemplateSet.class.php. Scroll down to the getTemplate() function, should be line 198. Replace the existing function with the following one:

public function getTemplate($tpl_name, $ret=false, $checkskin=true, $force_base=false)
{

 /* See if the file has been over-rided in the skin directory
  */
 if(strstr($tpl_name, $this->tpl_ext) === false)
 {
  $tpl_name .= $this->tpl_ext;
 }

 if(defined('ADMIN_PANEL') && ADMIN_PANEL === true){
  if(defined('ADMIN_SKINS_PATH') && file_exists(ADMIN_SKINS_PATH . DS . $tpl_name)){
   $tpl_path = ADMIN_SKINS_PATH . DS . $tpl_name;
  }
  else
  {
   $tpl_path = $this->template_path . DS . $tpl_name;
  }
 }

 if($force_base === true)
 {

  $old_tpl = $this->template_path;
  $this->template_path = Config::Get('BASE_TEMPLATE_PATH');

  if($checkskin === true)
  {
   if(defined('SKINS_PATH') && file_exists(SKINS_PATH . DS . $tpl_name))
   {
 $tpl_path = SKINS_PATH . DS . $tpl_name;
   }
   else
   {
 $tpl_path = $this->template_path . DS . $tpl_name;
   }
  }
 }
 if((!defined('ADMIN_PANEL') || $force_base == true) && $checkskin == true)
 {

  if(defined('SKINS_PATH') && file_exists(SKINS_PATH . DS . $tpl_name))
  {
   $tpl_path = SKINS_PATH . DS . $tpl_name;
  }
  else
  {
   $tpl_path = $this->template_path . DS . $tpl_name;
  }
 }

 if($force_base)
 {
  $this->template_path = $old_tpl;
 }
 if(!file_exists($tpl_path))
 {
  trigger_error('The template file "'.$tpl_path.'" doesn\'t exist');
  return;
 }

 extract($this->vars, EXTR_OVERWRITE);

 ob_start();
 include $tpl_path;
 $cont = ob_get_contents();
 ob_end_clean();

 # Check if we wanna return
 if($ret==true) 
  return $cont;

 echo $cont;
}

Save that too and close it. Now, you should be able to copy your files from admin/templates into admin/lib/[skin] and edit them there.

Any problems, let me know.

  • Like 2
Link to comment
Share on other sites

  • 10 months later...

Solved. Took an entire day, but solved. I've found a solution and it works for me, but please backup core/codon.config.php and core/classes/TemplateSet.class.php.

Open up codon.config.php and scroll down a bit until you see all the define() declarations. Add the following at the bottom:

define('ADMIN_PATH', SITE_ROOT.'admin');

Then, at the end of the file, add:

$admin_skin = Config::Get('ADMIN_SKIN');
define('ADMIN_SKINS_PATH', ADMIN_PATH.DS.'lib'.DS.$admin_skin);

Save your changes and close. Then, navigate to core/classes and open TemplateSet.class.php. Scroll down to the getTemplate() function, should be line 198. Replace the existing function with the following one:

public function getTemplate($tpl_name, $ret=false, $checkskin=true, $force_base=false)
{

/* See if the file has been over-rided in the skin directory
*/
if(strstr($tpl_name, $this->tpl_ext) === false)
{
$tpl_name .= $this->tpl_ext;
}

if(defined('ADMIN_PANEL') && ADMIN_PANEL === true){
if(defined('ADMIN_SKINS_PATH') && file_exists(ADMIN_SKINS_PATH . DS . $tpl_name)){
$tpl_path = ADMIN_SKINS_PATH . DS . $tpl_name;
}
else
{
$tpl_path = $this->template_path . DS . $tpl_name;
}
}

if($force_base === true)
{

$old_tpl = $this->template_path;
$this->template_path = Config::Get('BASE_TEMPLATE_PATH');

if($checkskin === true)
{
if(defined('SKINS_PATH') && file_exists(SKINS_PATH . DS . $tpl_name))
{
 $tpl_path = SKINS_PATH . DS . $tpl_name;
}
else
{
 $tpl_path = $this->template_path . DS . $tpl_name;
}
}
}
if((!defined('ADMIN_PANEL') || $force_base == true) && $checkskin == true)
{

if(defined('SKINS_PATH') && file_exists(SKINS_PATH . DS . $tpl_name))
{
$tpl_path = SKINS_PATH . DS . $tpl_name;
}
else
{
$tpl_path = $this->template_path . DS . $tpl_name;
}
}

if($force_base)
{
$this->template_path = $old_tpl;
}
if(!file_exists($tpl_path))
{
trigger_error('The template file "'.$tpl_path.'" doesn\'t exist');
return;
}

extract($this->vars, EXTR_OVERWRITE);

ob_start();
include $tpl_path;
$cont = ob_get_contents();
ob_end_clean();

# Check if we wanna return
if($ret==true)
return $cont;

echo $cont;
}

Save that too and close it. Now, you should be able to copy your files from admin/templates into admin/lib/[skin] and edit them there.

Any problems, let me know.

Ok, I'm just starting to experiment with the admin skin and I've followed your instructions above to point the admin templates to my skins folder. I have a few questions if you don't mind.

  1. For the main site, you choose the skin through the "general settings" in the admin dashboard which then points to the folder with your skin in it. How does it work with the admin one? I see there is no reference to a folder, so do I just copy all the templates I want for the admin skin into the main "skins" directory?
  2. For the main site, there is a template called "layout" which is the master file for the overall layout structure, then you get templates such as "fontpage_main" for the homepage content. How does it work with the admin as there is no "layout" file? Is it the "dashboard" file in the admin templates folder, or is it the index file in the main admin folder itself?
  3. I am trying to work out where to include my css and script link references. Should these be in the core_htmlhead template along with the other phpvms references? For the main site I have them in the "layout" file.

Apologies for the questions, I'm just trying to get my head around quite where to start as it's a bit different to skinning the main site.

Thanks

Harry

Link to comment
Share on other sites

Hi Harry,

Skinning the admin side seems different, though is very much similar to the main site.

1. The skin folder is in fact in admin/lib/layout . If you want to add a new one or start skinning the current one, make a new folder (or copy the layout one) and start skinning. To change the skin, you can do it one of two ways.

  • Rename the old "layout" folder to something else (e.g. layout1) and then rename your skin folder to "layout"
  • Or Add
    Config::Set('ADMIN_SKIN', 'YOURSKINNAME');
    


For the templates, I'm not sure whether you can just drag and drop the templates to the skin folder as I have tried and it didn't work (maybe have to adjust some code), but all the templates are in the admin/templates folder (it's mainly the same layout as the main site)

Main template files

  • core_navigation
  • dashboard

Your sidebar templates are called sidebar_pagename

2. The admin is based around the old skins format (This is in admin/lib/yourskinname)

  • The header file is your main skin file
  • The footer file is just for your footer
  • The layout file is for the quotes at the bottom under the footer

3. To include your css and script links, it is much like the "layout" file on the main side, you can put all your references in the "header" file, making sure you keep the skin elements.

  • Before your css references and after the rss references
    <?php
    Template::Show('core_htmlhead.tpl');
    ?>
    


  • Just after the <body>
    <?php
    Template::Show('core_htmlreq.tpl');
    ?>
    


  • Where you want your sidebar
    <?php
    Template::Show('core_sidebar.tpl');
    ?>
    


  • Where you want your core_navigation
    <?php
    Template::Show('core_navigation.tpl');
    ?>
    


I hoped this helped

Link to comment
Share on other sites

Thanks a lot Web541, I appreciate you sparing the time and giving me a comprehensive response.

I've created a new folder inside the admin "libs" folder. In there are my files for the skin I want to create including css, js etc. Just as a test I thought I would switch the default admin skin to the 'layout_dark' skin in the index.php file that sits in the main 'admin' folder. Nothing changed on my admin skin. It is still showing the default one.

Am I changing the wrong thing? No matter what I change it too, it always stays on the default skin.

Link to comment
Share on other sites

I tried itrob's explanation above and when I add his code into the 'TemplateSet.Class.php' file and it breaks my main front site. However, when I add his first two suggestions in and then change the 'layout' folder name with my skin name, it allows me to add my amended template files into my skin directory and they run from their. So this seems like an easy way to do it.

My challenge now is that I can't seem to trigger the js files to work. I have the filepaths set correctly because I've tested them with inspector and they are pointing to the right place. Any thoughts as to what might be stopping them functioning? I have them set at the end of the page as normal.

Link to comment
Share on other sites

Ok I am now making slow and painful progress but it's progress nonetheless :).

I've now managed to get the bones of my admin skin showing up and the js is now triggering which means I can now see everything on the page, albeit not quite in the right place yet. What I have noticed, just testing links to the default content in the admin panel, is that everything seems to work largely fine, except for the tables i.e. the pilot table (view all pilots) and the flight schedules & routes table.

Does anyone know if they are delivered via the "tablesorter" scripting built into phpvms or are they an iframe or something. I'll keep looking into it but if anyone knows in the meantime I'd greatly appreciate it.

Link to comment
Share on other sites

  • 2 months later...

Hi Harry,

Skinning the admin side seems different, though is very much similar to the main site.

1. The skin folder is in fact in admin/lib/layout . If you want to add a new one or start skinning the current one, make a new folder (or copy the layout one) and start skinning. To change the skin, you can do it one of two ways.

  • Rename the old "layout" folder to something else (e.g. layout1) and then rename your skin folder to "layout"
  • Or Add
    Config::Set('ADMIN_SKIN', 'YOURSKINNAME');
    


For the templates, I'm not sure whether you can just drag and drop the templates to the skin folder as I have tried and it didn't work (maybe have to adjust some code), but all the templates are in the admin/templates folder (it's mainly the same layout as the main site)

Main template files

  • core_navigation
  • dashboard

Your sidebar templates are called sidebar_pagename

2. The admin is based around the old skins format (This is in admin/lib/yourskinname)

  • The header file is your main skin file
  • The footer file is just for your footer
  • The layout file is for the quotes at the bottom under the footer

3. To include your css and script links, it is much like the "layout" file on the main side, you can put all your references in the "header" file, making sure you keep the skin elements.

  • Before your css references and after the rss references
    <?php
    Template::Show('core_htmlhead.tpl');
    ?>
    


  • Just after the <body>
    <?php
    Template::Show('core_htmlreq.tpl');
    ?>
    


  • Where you want your sidebar
    <?php
    Template::Show('core_sidebar.tpl');
    ?>
    


  • Where you want your core_navigation
    <?php
    Template::Show('core_navigation.tpl');
    ?>
    


I hoped this helped

I am working on skinning the admin template. How do you get the Content to show? No matter what I do, even taking the above codes out, the content is at the bottom of the screen. Is there something similar to the page content when placing content in the admin area, or is it in a different file than the header_tpl? The info works it's just on the bottom of the screen, instead of right of the sidebar? This reminds me of first trying to make a skin and how much trouble I had learning. Here we go again. If I don't give up. I am not even sure if I am doing this correctly. But I am trying.

http://screencast.com/t/JqAcrwIwTyu

And here is the top of the page:

http://screencast.com/t/Rc43B39RFELB

And what I am trying to replace the original sidebar with:

http://screencast.com/t/TT6zUiScpm

Thanks

Link to comment
Share on other sites

Hey jnascar,

The trick is to put these in the <div class="span9"> section

<div id="mainContent">
 <div id="results"></div>
 <div id="bodytext">

And then make sure this code is the last thing on the header.tpl as it continues on into the footer.tpl to end those </div> tags.

I am confused. Put what in the <div class="span9"> section? And add this code to the bottom of the header_tpl file?

<div id="mainContent">
 <div id="results"></div>
 <div id="bodytext">

Here we go again :) I will figure this out, I will. Man am I confused :)

Link to comment
Share on other sites

http://screencast.com/t/Mb7TlCVlddG

Alright it works on some of the items and some are still on the bottom, like view schedules, and it broke a lot of my links in the sidebar. But hey thanks to you I am closer. Can I send you a pm or not?

My links are back for some reason:

http://screencast.com/t/Xno4kTgx

Now do I add my template sidebar to the

  • core_navigation

I copied one item over and it works kind of:

http://screencast.com/t/1CREsGFrj9

The add and edit airline works on my new sidebar, but I can't figure out how to get ride of the original sidebar and replace it with the new sidebar from my template only.

And the dashboard is the main default info right?

  • dashboard

Thank you so much for your help Web541!

Link to comment
Share on other sites

  • 10 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...