Hello Björn,

thanks a lot, good idea to use functions.php and oxutilsView to load the admin includes even in oxajax.php and the overwritten templates from the module directory! Now I have everything loaded and packed nice and clean in my module dir, no need to copy anything into the core shop dirs anymore... sweet :)

If anybody else is using "admin/inc/...inc.php" file includes in custom modules, just add this to your functions.php file:

# add module admin dirs to include path to get the "admin/inc/*.inc.php" files working!
$aModuleDirs = glob( dirname(__FILE__) . '/*/admin/', GLOB_ONLYDIR);
$aModuleDirsVendor = glob( dirname(__FILE__) . '/*/*/admin/', GLOB_ONLYDIR);
$aIncludeDirs = array_merge( $aModuleDirs, $aModuleDirsVendor );
if (is_array($aIncludeDirs) && count($aIncludeDirs)) {
    foreach($aIncludeDirs as $sIncDir) {
        set_include_path(get_include_path() . PATH_SEPARATOR . $sIncDir);
    }
}

And for overwriting templates, create an oxutilsview module like so (of course, adjust name and paths used):
class smxb2b_oxutilsview extends smxb2b_oxutilsview_parent
{
    /**
     * Initializes and returns templates directory info array
     *
     * @return array
     */
    public function getTemplateDirs()
    {
        $myConfig = $this->getConfig();
        if ( !$this->isAdmin() ) {
$this->setTemplateDir( $myConfig->getModulesDir( true ) . "shoptimax/smxb2b_accounts/out/".$myConfig->getConfigParam( 'sTheme' )."/tpl/" );
        }
        else {
$this->setTemplateDir( $myConfig->getModulesDir( true ) . "shoptimax/smxb2b_accounts/out/admin/tpl/" );
        }
        return parent::getTemplateDirs();
    }
}

I guess I will write a little blog entry this week about all the little pitfalls when updating modules to Oxid 4.6...

Cheers,
Stefan

Am 14.05.2012 11:52, schrieb WBL Björn Lange:
Hello Stefan,

Am 11.05.2012 15:20, schrieb Stefan Moises:
This works for my admin class, but not for oxajax.php...
I also can't set the path for this include file in my metadata.php, because it isn't a "real" class like the main admin class:

    'files' => array(
'smxb2b_accounts_main' => 'shoptimax/smxb2b_accounts/admin/smxb2b_accounts_main.php', 'ajaxComponent' => 'shoptimax/smxb2b_accounts/admin/inc/smxb2b_accounts_main.inc.php',
        ...
I've tried to set the path for "ajaxComponent" as you can see, but of course this isn't working either...

So is there any way I can get oxajax to load my include file from the modules directory, or do I have to copy it over to the "/admin/inc/" dir of the shop (which would break the whole concept :P)

The "admin/inc/"-Container is identified by the "container"-parameter. The oxajax.php script is called directly and not through the shopcontrol, but the modules/functions.php is included. So you can set your include-path in this modules/functions.php to resolve "include_once 'inc/'.$sContainer.'.inc.php';" in oxajax.php on 748 (OXID 4.6.0). Did you try this allready?

And another "path question": is there a way to load the "bottomnavicustom.tpl" from my module folder, too? E.g. this doesnt seem to overwrite the default template:
    'templates' => array(
"bottomnavicustom.tpl" => "shoptimax/smxb2b_accounts/out/admin/tpl/bottomnavicustom.tpl", "smxb2b_accounts.tpl" => "shoptimax/smxb2b_accounts/out/admin/tpl/smxb2b_accounts.tpl",

The Module-Templates are saved in the config var "aModuleTemplates" which are called in oxconfig::getTemplatePath after the standard logic:

    public function getTemplatePath( $sFile, $blAdmin )
    {
$sTemplatePath = $this->getDir( $sFile, $this->_sTemplateDir, $blAdmin );

        if (!$sTemplatePath) {
            $sBasePath        = getShopBasePath();
$aModuleTemplates = $this->getConfigParam('aModuleTemplates');

So there is no way to "override" a default template with this way. But i suggest to overload oxUtilsView::getTemplateDirs to add your own template dir first for overwriting this template and load your template first.

Regards,
Björn


--
Mit den besten Grüßen aus Nürnberg,
Stefan Moises

*******************************************
Stefan Moises
Senior Softwareentwickler
Leiter Modulentwicklung

shoptimax GmbH
Guntherstraße 45 a
90461 Nürnberg
Amtsgericht Nürnberg HRB 21703
GF Friedrich Schreieck

Tel.: 0911/25566-0
Fax:  0911/25566-29
moi...@shoptimax.de
http://www.shoptimax.de
*******************************************


_______________________________________________
dev-general mailing list
dev-general@lists.oxidforge.org
http://dir.gmane.org/gmane.comp.php.oxid.general

Reply via email to