Which variables are available in the theme?

I would like to know what data I can access and what, exactly, it represents and when it is available. I am aware of [{debug}], but that still doesn’t tell me much.

For instance the $oxcmp_categories (btw what does the cmp stand for?) variable. It contains an oxCategoryList Object. That doesn’t tell me anything about how to access stuff inside it (or what data is inside it. Probably categories, but how to get them? No clue.)

Same with the $oViewConf or $oView variable. Where can I see what I can access or if there are any conditions as to when the var will even be available (or what it holds, or if only parts of it will be available in some place but not in another)?

I’m hoping someone can clear up this mystery for me, because it’s been giving me headaches for weeks.


are you familar with the mvc?

basically you have a php controller, which collects data, does some magic und passes this data to smarty to render the views / templates. Sometimes you will find something like this in the templates:

$this->_aViewsData["product"] = $oArticle;

which are the same and mean, that php “sends” the $oArticle object to the view and in this case you will be able to access this object in the teplate by using [{ $product }]

you can access the functions of your controller by using [{$oView->function()}], here you can find the reference of all functions: http://docu.oxid-esales.com/CE/sourcecodedocumentation/
most controllers have different functions, but they also share some.

another special class is the oxViewConfig, in the template you can access it by [{$oViewConf}], it contains some additional functions and parameters all around the view rendering and its accessible everywhere and its always one the same oxViewConfig. Have a look at the documentation for its functions.

ok, this oxcmp_ stuff… “cmp” means “component”. there are some important classes implemented as components, they are like oxViewConfig and you can access them everywhere in the tenplate.
e.g. oxcmp_user is the current shop visitor.

the usual data flow in templates looks like this:

  • check what you need
  • check the documentations if there is a function for getting this
  • [{$oView->getThatStuff()}]

often there will be no function for this, you you will be able to get the data you need over other objects you can get from oVIew
e.g. on the product page you get your active product from the oView and then you can get alls the product data from the product object.

I’ve heard of MVC before, but I have never worked with it, so the concept is new to me.

In any case thank you. This helps.

One thing though: how do I know about things like being able to iterate over oxCategoryList-Object with foreach, which are not really obvious? I just stumbled over this in the template code, and it had me confused because I wouldn’t expect foreach working on an object.

there are several types of classes in OXID

  1. models and core objects, they all start with “ox” like oxArticle, oxViewConfig, oxConfig, oxOnlineModuleVersionNotifier
    they contain the data

  2. special list classes, like oxArticleList, oxCategoryList, oxUserList, oxActionList
    they are lists of the model objects. This list classes implement some special magical php array iteration functions, so you can iterate them with foreach loops or even use as lists and go through them with next() and prev() functions.

  3. controller (front and backend), they have more user friendly names, like details, basket, alist. (article list, basically just a category)

as i was new to oxid, i had lots of problems with iterating throug such arrays/lists in smarty and also getting the data from this list classes. Have a look at the oxArticleList in the documentation, or just in the php file itself. There you will find something like this:

class oxarticlelist extends oxlist

so technically you have all the functions of oxArticleList and oxList inside the object.
And when you iterate the List object with a foreach loop, you will get the oxArticle Objects as items, sou you can use all the functions of the oxArticle class

Thanks a lot for this clarification. If this information had been in the wiki, it would’ve saved me a [B]lot[/B] of time. Is it really that obvious that it doesn’t need to be mentioned anywhere in the theme related pages?

The last place I would look when designing a theme would be the PHP source code documentation. Especially since templating with Smarty is supposed to enable non-programmers to work with it (which I still highly doubt, but that’s a different topic).

some stuff is pretty basic knowledge, like mvc or oop php. But there is leak of the information about OXID basics, like the oxcmp_ stuff and viewconfig.

unfortunately, most of the documentation is in german language and since the website relaunch last year all the documentation was moved into the archive where its hard to find even if you know what you are looking for and where you have to look.

in german subforum we actually plan to collect, reorganize and update some documentation for new oxid users and also for new oxid developers. But it will take a lot of time since we all have our jobs and families. I guess, the finished documentation will be already outdated because of some major releases and coming changes

you could say “nobody aint got time for that” :smiley:

The woes of open source software, I suppose. I actually prefer the international forum now, though. It seems on the german forum I often either get no or snappy responses.

In any case, thanks for your time and help, I appreciate it.