0

I'm trying to modify an admin template by overriding it (instead of modifying the core template file directly).

So the way I understand it, I should just be able to copy a template file: app/design/adminhtml/default/default/template/catalog/product/edit/websites.phtml

to: app/design/adminhtml/default/companyname/template/catalog/product/edit/websites.phtml

Here's the tricky part: it works for just about every page except for the page I need it to work on. I'm trying to copy any of the templates used by Catalog->Products->->Custom Options

I can't seem to override any of those templates. I've cleared every cache I own (even from my wallet just to be sure). I've double checked all file names and paths.

I can't find error messages that would be helpful to give me a hit to what's going on, so I'm hoping somebody had run across this before or might be able to point me in the direction

At the very least at some hidden logs somewhere that might tell me what's going on?

Edit: After digging into this more, we came up with an interesting find: the default theme is customtheme and the override template is default, only for this section. Everywhere else, default is default and override is customtheme. We still have no idea why.

2
  • 1
    How is the customtheme value set in your system? One possibility is this was done in a non-standard way, and it's being skipped for the product options theme. Feb 10, 2014 at 19:11
  • Have you grepped your codebase for customtheme? Either in PHP or in XML, this has to be set somewhere.
    – benmarks
    Feb 10, 2014 at 20:16

2 Answers 2

3

Assuming you've setup Magento's admin area to use comapnyname, as per Ben's answer, if you're still running into trouble, I'd jump right to the source.

The Mage_Core_Model_Design_Package class is where Magento decides which files to use for a theme. First the current theme is checked. If nothing's found there, then the default theme is checked. That check happens here

#File: app/code/core/Mage/Core/Model/Design/Package.php
public function validateFile($file, array $params)
{
    $fileName = $this->_renderFilename($file, $params);
    $testFile = (empty($params['_relative']) ? '' : Mage::getBaseDir('design') . DS) . $fileName;
    if (!file_exists($testFile)) {
        return false;
    }
    return $fileName;
}

I'd temporarily add some poor man's logging to this function to see the file's Magento is actually accepting or rejecting during a request.

#File: app/code/core/Mage/Core/Model/Design/Package.php
public function validateFile($file, array $params)
{
    $fileName = $this->_renderFilename($file, $params);
    $testFile = (empty($params['_relative']) ? '' : Mage::getBaseDir('design') . DS) . $fileName;
    if (!file_exists($testFile)) {
        file_put_contents('/tmp/design-files.log',"REJECT: $testFile\n",FILE_APPEND);
        return false;
    }
    file_put_contents('/tmp/design-files.log',"ACCEPT: $testFile\n",FILE_APPEND);        
    return $fileName;
}

My guess is you've got a subtle, hard to spot typo in one of your file paths. Try

ls -l [filename]

with the results from the above logging.

Update: Based on the comments you've made, it sounds like you're working with a system where someone has customized things to work differently, and the behavior is a side effect on that.

The two tacts I'd take on debugging this are

  1. Figure out how your system sets the value for customtheme, and why this code isn't called when the page renders the Custom Options section

  2. The custom options are rendered via ajax. Normally, this is with a URL that looks like the following

    http://magento.example.com/index.php/admin/catalog_product/options/id/166/key/2d18a7efe76c64829ba80b26aa153875/?isAjax=true

and the render is handled in the optionsAction method of

app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php

I'd look into if this is different on your system, either via a URL rewrite or a controller override of some kind. This may explain why this particular URL is ignoring the custom theme.

Good luck!

5
  • Ok, here's an interesting variable to add. We found out the default theme is customtheme and the override template is default, only for this section. Everywhere else, default is default and override is customtheme. Feb 10, 2014 at 17:35
  • @FrancisLewis Just a guess, but are you confusing the frontend theme and adminhtml theme? Setting a custom theme for the frontend is done via the configuration UI, but this does not override the theme for the backend admin area. Feb 10, 2014 at 17:38
  • I wish I were confusing the two, unfortunately I'm not. Feb 10, 2014 at 17:46
  • 1
    @FrancisLewis Updated the answer with some possible theories. You're almost certainly working with a system that's been customized to work differently in some way, and the behavior you're seeing is a side effect of that customization. This means it'll be hard for a stranger on the internet to solve this problem for you. Good luck! Feb 10, 2014 at 19:21
  • Oh crud, changes were made to the Page file :( Yes, you're correct. Now I just have to track down what changes were made and why. Thanks! Feb 10, 2014 at 20:08
3

If you want to do this you'd have to set the theme for the admin store, and this cannot be done via the Admin panel. Add the following to your app/etc/local.xml file:

<stores>
    <admin>
        <design>
            <theme>
                <template>companyname</template>
            </theme>
        </design>
    </admin>
</stores>
4
  • I did mention that it works everywhere else on the site, so unfortunately I can't be of more help on my question, but this doesn't point me in the right direction. Feb 10, 2014 at 17:33
  • "it works everywhere else on the site" - I'm sure that it does. However, the theme settings in the admin panel apply to the frontend design area only. This means that if you wish to have the same settings for the adminhtml design area, you have to add these settings manually to a configuration XML file (as my solution suggests.)
    – benmarks
    Feb 10, 2014 at 19:34
  • I'm specifically talking about the admin area, not the frontend. When I say "working everywhere else", that's everywhere in the admin section. Feb 10, 2014 at 20:07
  • 1
    AH, I understand. Looking at your update, the custom theme has been implemented in a nonstandard/inappropriate way.
    – benmarks
    Feb 10, 2014 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.