display user info in page list
Permalink Browser Info Environment
Hi Willem,
I still love this add-on. The site i'm using it on is now a multi-lingual website, also the translated attributes are displaying right through the user info block.
My problem is when using the user info code in a page list. I know, that's not exactly related to your user info block, but i thought you could maybe help me getting this right.
I'm using this code to display user attributes in my pagelist block to display some author information in the list:
This works great and displays the value of the user attribute. But i want it to display the translated value. So i tried this:
Als tried the above with the last line changed to
But this displays empty. Do you have a clue on what code i should use to display the translated values? Your help is very much appreciated!
I still love this add-on. The site i'm using it on is now a multi-lingual website, also the translated attributes are displaying right through the user info block.
My problem is when using the user info code in a page list. I know, that's not exactly related to your user info block, but i thought you could maybe help me getting this right.
I'm using this code to display user attributes in my pagelist block to display some author information in the list:
<?php $c = Page::getCurrentPage(); //get the current page to work with it's information $uID = $c->getCollectionUserID(); //gets the User ID of the Page Owner $ui = UserInfo::getByID($uID); //with the User ID, load a UserInfo object echo $bioFunction ?>
This works great and displays the value of the user attribute. But i want it to display the translated value. So i tried this:
<?php $c = Page::getCurrentPage(); //get the current page to work with it's information $uID = $c->getCollectionUserID(); //gets the User ID of the Page Owner $ui = UserInfo::getByID($uID); //with the User ID, load a UserInfo object if (!$c->isMasterCollection()) { $bioFunction = $ui->getCollectionAttributeValue('bio_function'); //Custom select attribute echo tc('SelectAttributeValue', $ui->getCollectionAttributeValue('bio_function')); } ?>
Als tried the above with the last line changed to
echo tc('SelectAttributeValue', $bioFunction = $ui->getCollectionAttributeValue('bio_function'));
But this displays empty. Do you have a clue on what code i should use to display the translated values? Your help is very much appreciated!
Type: | Pre-Sale |
---|---|
Status: | Resolved |
Hi Buurvrouw,
I didn't test this on your specific issue, but:
$value = $ui->getAttributeValueObject($ua);
if (is_object($value)) {
$attval = $value->getValue('displaySanitized', 'display');
}
may do the trick.
You can check how I used it In my getUserAttributes() function
-----
On a different note: I've been working on a new version for UserInfo.
Some of the changes will be:
- added translation, including dutch language
- fixed redactor dropdownmenu problem when switching tabs
- faster code (rewritten cascade calls)
- cleaned up and restructured a lot of the code (config, editors, content, save)
- save config in application file instead of database
specific 8.0 changes:
- attributes compatible with 8.0
- ckeditor plugin (redactor plugin still available for 5.7 installs)
- replaced deprecated UserInfo::getByID
I'm not sure yet when it will be released, but I'll try to have it available before v8 launches.
I didn't test this on your specific issue, but:
$value = $ui->getAttributeValueObject($ua);
if (is_object($value)) {
$attval = $value->getValue('displaySanitized', 'display');
}
may do the trick.
You can check how I used it In my getUserAttributes() function
-----
On a different note: I've been working on a new version for UserInfo.
Some of the changes will be:
- added translation, including dutch language
- fixed redactor dropdownmenu problem when switching tabs
- faster code (rewritten cascade calls)
- cleaned up and restructured a lot of the code (config, editors, content, save)
- save config in application file instead of database
specific 8.0 changes:
- attributes compatible with 8.0
- ckeditor plugin (redactor plugin still available for 5.7 installs)
- replaced deprecated UserInfo::getByID
I'm not sure yet when it will be released, but I'll try to have it available before v8 launches.
Ah thanks for the quick reply and pointing out the direction for a solution, i'm gonna try to get this working.
And this update sounds great!
And this update sounds great!
Managed to do this with your directions:
Put this in the 'foreach' function in the page list template:
And then echo $attval somewhere you want to display the value.
Thanks for your help Willem!
Put this in the 'foreach' function in the page list template:
$uID = $page->getCollectionUserID(); //gets the User ID of the Page Owner $ui = UserInfo::getByID($uID); //with the User ID, load a UserInfo object if (!$page->isMasterCollection()) { $yourVariable = $ui->getAttributeValueObject('your_attribute'); //Custom Select attribute if (is_object($yourVariable)) { $attval = $yourVariable->getValue('displaySanitized', 'display'); } }
And then echo $attval somewhere you want to display the value.
Thanks for your help Willem!
Yes, that looks nice. Glad you got it working.
I need to get the bio_function. This is a user select attribute with 3 values.