Hi,
I have so informations for user in extended section.
for example a container “stats” with “contacts:5”
In UpdateProfile I get it via [[+stats.contacts]].
but with:
[[!+modx.user.id:userinfo=
extended.stats.contacts]]
there show me nothing.
What do I make wrong?
thank you in advance.
bye
Chris
fritzkola:
What do I make wrong?
Looking at the code, it seems that it is just one level to deep to work with this output modifier.
case 'userinfo':
/* Returns the requested modUser or modUserProfile data (input: user id) */
if (!empty($output)) {
$key = (!empty($m_val)) ? $m_val : 'username';
$userInfo= null;
/** @var modUser $user */
if ($user= $this->modx->getObjectGraph('modUser', '{"Profile":{}}', $output)) {
$userData = array_merge($user->toArray(), $user->Profile->toArray());
unset($userData['cachepwd'], $userData['salt'], $userData['sessionid'], $userData['password'], $userData['session_stale']);
if (strpos($key, 'extended.') === 0 && isset($userData['extended'][substr($key, 9)])) {
$userInfo = $userData['extended'][substr($key, 9)];
} elseif (strpos($key, 'remote_data.') === 0 && isset($userData['remote_data'][substr($key, 12)])) {
$userInfo = $userData['remote_data'][substr($key, 12)];
} elseif (isset($userData[$key])) {
$userInfo = $userData[$key];
}
}
$output = $userInfo;
} else {
$output = null;
I suspect you have to write a custom snippet (or a custom output modifier).
thank you.
I am thinking how I could cutom output modifier to extend these feature.
what is “remote_data.” ?
The easiest solution is probably to use a custom snippet to output all the user data at once.
Something like this:
Snippet “outputUserData”
<?php
$tpl = $modx->getOption('tpl', $scriptProperties, '');
$profile = $modx->user->getOne('Profile');
if ($profile){
$userData = array_merge($modx->user->toArray(), $profile->toArray());
return $modx->getChunk($tpl, $userData);
}
Chunk “myUserTpl”
<h2>[[+username]]</h2>
<div>
[[+email]]<br>
[[+extended.stats.contacts]]
</div>
Snippet Call
[[!outputUserData? &tpl=`myUserTpl`]]
fritzkola:
what is “remote_data.” ?
The class modUser
has a field remote_data
. I don’t think that it is used anywhere in MODX.
Probably one of those legacy fields that had a purpose once.