Jump to content

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


Recommended Posts

Posted (edited)

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
Posted
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. 

Posted

Hi Ryan

Just to follow up

i will, definitely. Who wants not follow the revelation of st. P.W. Cramer?

Posted

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).

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
  • Recently Browsing   0 members

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