Jump to content

include pw in another app: class conflict "Cannot redeclare class..."


stefan
 Share

Recommended Posts

Hello Guys

there is another app (foolish xtmshop) with smarty engine and i include pw inside some smarty functions

example


<?php
require_once '_w/index.php';
function smarty_function_getWireProduct($params, &$smarty)
{
    if( $oProduct = wire('pages')->get('/produkte/' . $smarty->_tpl_vars['PRODUCTS_MODEL'] . '/') ) {
        $smarty->assign('wireProduct', $oProduct);
    }
    return null;
}

few minutes ago i installed the Language Support (german Language pack) and all works fine. But the app also use a class "language" so this run into the "cannot redeclare class language" error.

Any ideas how to prevent this?

Thanks in advance

adios, Stefan

Edit:

Ok. i see... there are a lot of related topics around. But not a quick solution, right? Waiting for namespaces...

Edited by stefan
Link to comment
Share on other sites

Ok. i see... there are a lot of related topics around. But not a quick solution, right? Waiting for namespaces...

Just to follow up, you are right that namespaces will solve this. And they are coming in 2.4. Otherwise, the only options are to rename one of the classes (and anything referencing that name), or let your applications talk to each other via some other route, like web services. 

Link to comment
Share on other sites

HA! All of them are joining the new hope :-) Welcome Stefan (oldschool MODX hacker, we had a lot of ideas, among which got developed by him, most of them were dropped because of... well. The system.)

Stefan, gimme a call (friday perhaps when all are eating their rabbits).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...