How does the template override work?

I have tried to understand, how the a.m. topic is technically implemented, but was not really successful…

I have searched the OXID-code for references to “sCustomTheme”, but only found 1 usage in “[B]oxconfig.php[/B]”:

        // Check for custom template
        $sCustomTheme = $this->getConfigParam( 'sCustomTheme' );
        if( !$blAdmin && $sCustomTheme && $sCustomTheme != $sTheme) {
            $sReturn = $this->getDir($sFile, $sDir, $blAdmin, $iLang, $iShopl, $sCustomTheme, $blAbsolute, $blReturnArray);
        }

which does not really explain to me, how it works…

Can anybody help me out here?

Hello,

actually the answer is already in pasted code lines.

Most directory getter functions use oxconfig::getDir which takes theme as a parameter.


// see this simplified code
class oxConfig {
    function getDir ($sTheme,...) {
        if($sCustomTheme) {
            $sResult = $this->getDir($sCustomTheme,...);
        }
        //check lang, shop, theme, out levels
        //put to cache
    }
}

To fix smarty internal includes we added function oxUtilsView::_smartyDefaultTemplateHandler as callback for Smarty’s default_template_handler_func, which searches for template using oxConfig::getDir() .

more general information how to use it, was added in release notes http://www.oxid-esales.com/en/news/blog/new-major-version-420-oxid-eshop-released

A Template Override System for an easier design customization maintenance was implemented. A new option sCustomTheme was added to config.inc.php for this reason that you have to fill with the value of your choice, e.g. ‘custom’. Now, make a new directory with the same name (custom) and structure as you know it from basic and copy all of your adapted tpl-files to this location. The shop will now look up if there is an adapted file in your custom folder; if not it will return to the basic folder. This works for included files as well,

Hope it helped.

Alfonsas

[QUOTE=alfonsas cirtautas;17705]Hope it helped.[/QUOTE]
Yes, it did.

THX for the info.

Just wanted to tell you, that I have converted my template for version 4.2.0 to use the “template override”-feature.

It works like a charm!

I have separated the template like follows:

everything [B]but [/B]

css, button-graphics, box-header-graphics and any graphics specific to a user template, [B]plus[/B] my central structure-definition template “_index.tpl” and my template configuration files

went into the [B]main [/B]template, the a.m. items into the “[B]override[/B]” template…

I also tested overriding one of my “box”-templates (which is necessary now and then if a customer wants a different layout) by copying it into the “override” template-structure, and it [B]really [/B]has taken precedence over the one in the main template!

Very nice indeed!

This feature will help [B]a lot [/B]in getting a better organisation within the template-system, so that you need to maintain the vast majority of the template files for [B]all [/B]your customers’ templates [B]only once[/B]!

But, at the same time, still preserving the necessary flexibility to support [B]any [/B]thinkable designs…

[B]So one big issue for me with OXID templating is resolved![/B]

Technically speaking the underlying template files for our first OXID 4 CE customer shop at http://www.digital-readers.de/ has become [B]my(!)[/B] standard-template now, it has got all the hooks and bells and whistles I will need to create all other shop designs we will do.

From experience with xtcommerce (where I use my own template overriding) typical candidates for overriding will be the css-files, “product.tpl”, “details.tpl” (maybe some “boxes” now and then) and my “[B]_index.tpl[/B]” for defining the overall shop structure.

So you can achieve [B]any [/B]shop design and layout rather elegantly…

And, what is at least as important, it is [B]maintainable [/B]even for a large customer base…

The template overriding is really a big advance.

(As a matter of fact, if it were not supported now in the shop core, I would have done it myself (like in xtcommerce)!)

I tried to use this feature, it worked for the templates, but I started getting 404s for images, so there maybe a bug in the path-getter there somewhere.

Sorry to not be more specific here, but I tried it a while ago…

Best,
Achim

PS: Did you NOT have this image problem?

[QUOTE=oxal;22545]PS: Did you NOT have this image problem?[/QUOTE]
No, and there is no reason you should have one…

The template, override-template and pictures directories are on the same level.

I.e.: the pictures have nothing to do with the tempate(s) at all.