Prev | Current Page 242 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"


This example demonstrates how we can set the user's foo parameter and save the
changes to the database:
// get the user and add the foo parameter
$user =& JFactory::getUser();
$user->setParam('foo', 'bar');
// update the raw user parameters
$params =& $user->getParameters();
$user->set('params', $params->toString());
// save the changes to the database
if (!$user->save())
{
JError::raiseError('SOME_ERROR', JText::_('Failed to save
user'));
}
Next we will explore parameters that a user can update via a form. We will begin by
creating an XML file that defines the extra parameters. We will see the parameters in
detail in the Appendix. The following XML defines two text parameters, myparameter
and myotherparameter:



label="My Parameter" description="An example user
parameter" />
label="My Other Parameter" description="An example user
parameter" />


We can create form elements using this XML and the user's JParameter object.


Pages:
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
mieszkania życzenia dieta light pozycjonowanie wierszyki