# Use functions in different modules

**URL:** <https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354>\
**Category:** English forums\
**Tags:** modules\
**Created:** [December 14, 2011, 5:07pm UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354 "2011-12-14T17:07:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![avalue](https://forum.oxid-esales.com/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@avalue](https://forum.oxid-esales.com/u/avalue)\
**Post date:** [December 14, 2011, 5:07pm UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354/1 "2011-12-14T17:07:18Z")

</div>

Hello everyone,

i have two custom modules that export some data to csv. In some parts they are identical, for example there are many functions that both modules need. So to avoid double-code my first idea was to extend the module from a module/class that holds the functions.

Then i saw the modules/functions.php file.

I would prefer method 1 tho.

What would be the best way for doing this in OXID?

---

<div class="post-metadata">

**Author:** ![rafaeldabrowski](https://forum.oxid-esales.com/letter_avatar_proxy/v4/letter/r/e9bcb4/32.png) [@rafaeldabrowski](https://forum.oxid-esales.com/u/rafaeldabrowski)\
**Post date:** [December 14, 2011, 5:10pm UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354/2 "2011-12-14T17:10:14Z")

</div>

Depends on what this functions are doing, can you be a bit mor precise ?

regards

Rafael

---

<div class="post-metadata">

**Author:** ![avalue](https://forum.oxid-esales.com/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@avalue](https://forum.oxid-esales.com/u/avalue)\
**Post date:** [December 14, 2011, 5:50pm UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354/3 "2011-12-14T17:50:41Z")

</div>

for example number / money formatting, get charset, mainly functions used in oximex.php for the lexware export

---

<div class="post-metadata">

**Author:** ![rafaeldabrowski](https://forum.oxid-esales.com/letter_avatar_proxy/v4/letter/r/e9bcb4/32.png) [@rafaeldabrowski](https://forum.oxid-esales.com/u/rafaeldabrowski)\
**Post date:** [December 14, 2011, 6:03pm UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354/4 "2011-12-14T18:03:21Z")

</div>

ok charset you can get via  
$oxConfig::getInstance()-\>isUTF();

Numberformating:  
First getting Currency object, then you can use it for formating.

```php

$sName = "USD"; // Name of Currency entered in backend
$oCur = $oxConfig::getInstance()->getCurrencyObject( $sName );
$oCur->rate; // Exchange rate;
$oCur->dec; // decimal seperator
$oCur->thousand; // thounsands seperator
$oCur->sign; // currency sign
$oCur->decimal; //decimal precision

```

---

<div class="post-metadata">

**Author:** ![avalue](https://forum.oxid-esales.com/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@avalue](https://forum.oxid-esales.com/u/avalue)\
**Post date:** [December 15, 2011, 10:37am UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354/5 "2011-12-15T10:37:18Z")

</div>

thanks for your advice, rafael. but it would be very nice to know what would be the best way if i have some custom (own) functions that i want to use in 2 or more different modules.

---

<div class="post-metadata">

**Author:** ![rafaeldabrowski](https://forum.oxid-esales.com/letter_avatar_proxy/v4/letter/r/e9bcb4/32.png) [@rafaeldabrowski](https://forum.oxid-esales.com/u/rafaeldabrowski)\
**Post date:** [December 15, 2011, 10:46am UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354/6 "2011-12-15T10:46:22Z")

</div>

I just wanted to show you that you do not need to allways reinvent the wheel 😉  
but you can have a look at the oxcmp classes or the oxutils: [http://docu.oxid-esales.com/CE/sourcecodedocumentation/4.5.0.34568/](http://docu.oxid-esales.com/CE/sourcecodedocumentation/4.5.0.34568/)

Regards

Rafael

---

<div class="post-metadata">

**Author:** ![avalue](https://forum.oxid-esales.com/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@avalue](https://forum.oxid-esales.com/u/avalue)\
**Post date:** [December 16, 2011, 10:16am UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354/7 "2011-12-16T10:16:29Z")

</div>

Thanks, Rafael. Seems that i should take a closer look at oxid own things.

Could i extend a module (like mymodule =\> mysecondmodule) or instead of using mymodule\_parent just use a class with all functions i need in it? (just an idea)

---

<div class="post-metadata">

**Author:** ![rafaeldabrowski](https://forum.oxid-esales.com/letter_avatar_proxy/v4/letter/r/e9bcb4/32.png) [@rafaeldabrowski](https://forum.oxid-esales.com/u/rafaeldabrowski)\
**Post date:** [December 16, 2011, 10:32am UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354/8 "2011-12-16T10:32:27Z")

</div>

If you insist to have your own class you can create one and put it into the /core folder.  
just extend something like oxI18n.  
Definition:

```php

class yourClass extends oxI18n
{
...
}

```

Call:

```php

//public functions
$oClass = oxNew('yourClass');
$oClass->yourFunction(); 

//or static functions
yourClass::yourFunction(); 

```

But it is a bit of bad habbit in an MVC Enviroment.

Regards

Rafael

---

<div class="post-metadata">

**Author:** ![vanilla\_thunder](https://forum.oxid-esales.com/user_avatar/forum.oxid-esales.com/vanilla_thunder/32/72_2.png) [@vanilla\_thunder](https://forum.oxid-esales.com/u/vanilla_thunder)\
**Post date:** [December 16, 2011, 10:41am UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354/9 "2011-12-16T10:41:29Z")

</div>

you can extend modules, but not the way you describe it, and there is actually no need for extending modules.

e.g. you’ve got a car, “car” is a class, and it can drive, tun around, switch the lights on and off.  
now you can get a module “tuning” which contains some additional functions like playing music, some lowrider funtionality but it can also make your car drive faster (its called function override)

technically this module says to the oxid shop “take all my functions and put them into the parent class”, you have to write inside the module section in backend which class you want to exted, like “myCar =\> tuning”.

you can create an own class with all your functions, but the shop’s module system is already the easiest way to keep an eye on changes you have done in the shop and also keep them after a shop update.

---

<div class="post-metadata">

**Author:** ![system](https://forum.oxid-esales.com/user_avatar/forum.oxid-esales.com/system/32/4245_2.png) [@system](https://forum.oxid-esales.com/u/system)\
**Post date:** [July 13, 2026, 7:39pm UTC](https://forum.oxid-esales.com/t/use-functions-in-different-modules/54354/10 "2026-07-13T19:39:00Z")

</div>

Closed on July 13, 2026, 7:39pm UTC


