revolution icon indicating copy to clipboard operation
revolution copied to clipboard

Bug with getting information about the context

Open Semdevmaster opened this issue 4 years ago • 2 comments

Bug report

Summary

In templates or snippets $modx->context->key;//works fine $modx->context->rank;//works fine $modx->context->name;//does not work (always empty string) $modx->context->description;//does not work (always empty string)

Step to reproduce

create a snippet that returns data from the current context

Observed behavior

in all templates and snippets when requesting current context data, only key and rank available Name and description are always empty, although filled in the admin panel But $res = $modx->getObject('modContext',['key'=>'web']); print_r($res->toArray()); Array ( [key] => web [name] => Москва [description] => Москва [rank] => 0 ) Works fine

Expected behavior

$modx->context->name;//should output the data from admin panel $modx->context->description;//should output the data from admin panel

Related issue(s)/PR(s)

Environment

MODX 2.8.1

Semdevmaster avatar Apr 08 '21 11:04 Semdevmaster

The name and description of the context have never been part of the data stored in the context cache which is used to load a context when initialized. This may seem like a bug as you might expect that data to be available in the templates/snippets, but it is a feature request.

opengeek avatar Sep 01 '21 16:09 opengeek

If I'm not mistake the rank property isn't part of the data that's stored in the cache either. In the reporters example $modx->context->rank returns 0 because it's the default value for the property.

JoshuaLuckers avatar Sep 07 '21 09:09 JoshuaLuckers