Letting a user edit their account details in Xaraya

Once someone has registered on your nice new web site, it would be useful if they could then edit and change their own account details. Well, of course, they can if they can find the link to their account. There should really be a link on the menu underneath the Logout link, which can, like the Logout link, be set via the admin menu. Here I’ll describe how to add that link to the menu.

The link to a users account details is very simple: /index.php/roles/account/roles This will automatically check if the user is logged in, and if so, will pull up the relevant account details page in Edit mode.

So, it’s just simply a matter of putting that link in the menu tree then? Well, not so simple, because we want that link to show only if the user is logged in, otherwise not. And it is difficult to code that into the menu block through the admin screens. I mentioned above that it would be nice to have that link appear above the Logout link and to only appear when the Logout link appears.

Turns out that this is quite easy, we’ll just find the code for the logout link, duplicate it (with some modification) for the Edit Account link and voila!

It turns out that the code for the logout link is in modules/base/blocks/menu.xd. This being Xaraya, we don’t modify the core code but create an override template by copying the modules/base/blocks/menu.xd to themes/MyTheme/modules/base/blocks/menu.xt (where ‘MyTheme’ is the name of your theme) and modify it so:

Look for section on ‘Logout only if not admin or anomymous’ (line 110 approx)
Add in this:
<xar:set name="modurl">xarModURL('roles','user','account',array())</xar:set>
and a link:
[<a href="#$modurl#"><xar:mlstring>Edit Account</xar:mlstring></a>]

That should be all that is needed.

Comments are closed.