abdfahim
Well-known member
In XF1, if we want to display certain custom fields in a page, I just return the corresponding fields. For example, in account/personal-details page, the actionPersonalDetails only returns the UserFileds with display_group = 'personal'.
But, when I was trying to inspect the same in XF2, it seems like the actionAccountDetails() function returns all data, and the filtering is done inside the template.
So, if I want to create a dedicated page for, say, all the custom fields with display_group = 'personal', should I go in the same way? I thought if I could return only the respective fields, it would be more optimized.
Code:
public function actionPersonalDetails()
{
...............................
$customFields = $this->_getFieldModel()->getUserFields(
array('display_group' => 'personal'),
array('valueUserId' => $visitor['user_id'])
);
.............................
}
But, when I was trying to inspect the same in XF2, it seems like the actionAccountDetails() function returns all data, and the filtering is done inside the template.
Code:
public function actionAccountDetails()
{
$view = $this->view('XF:Account\AccountDetails', 'account_details');
return $this->addAccountWrapperParams($view, 'account_details');
}
So, if I want to create a dedicated page for, say, all the custom fields with display_group = 'personal', should I go in the same way? I thought if I could return only the respective fields, it would be more optimized.
PHP:
public function actionPersonal()
{
if ($this->isPost())
{
$visitor = \XF::visitor();
if ($visitor->canEditProfile())
{
$this->personalSaveProcess($visitor)->run();
}
return $this->redirect($this->buildLink('account/personal'));
}
else
{
$view = $this->view('XF:Account\Personal', 'abdfahim_account_personal');
return $this->addAccountWrapperParams($view, 'abdfahim_account_personal');
}
}