[solved] My account menu for users (same as admin)

Author Message

Nathan Kelly

Thursday 24 November 2005 9:02:41 pm

Hi all, I've been racking my brain trying to get this working, so this is my last resort.

I would like to create a "My Account" menu for my users similar to the one in the admin area (left hand menu when in My Account), this way when a user is logged in they can go to their account settings and a menu will be present.

In the menu I need a link to change notification settings, user profile and a couple of other links like a help link where they can get info on how to edit their account etc.

I've been looking in the admin templates and I have found in the pagelayout.tpl the code that performs this in the admin area, however I have so far been unsuccessful adapting it to the front end.

This is the code from admin pagelayout.tpl

{section show=and( eq( $ui_context, 'edit' ), eq( $ui_component, 'content' ) )}
{section-else}
<div id="leftmenu">
<div id="leftmenu-design">

{section show=and( $ui_context|eq( 'edit' ), $ui_component|eq( 'content' ) )}
    {include uri='design:edit_menu.tpl'}
{section-else}

{section show=eq( $navigation_part.identifier, 'ezcontentnavigationpart' )}
    {include uri='design:parts/content/menu.tpl'}
{/section}

{section show=eq( $navigation_part.identifier, 'ezmedianavigationpart' )}
    {include uri='design:parts/media/menu.tpl'}
{/section}

{section show=eq( $navigation_part.identifier, 'ezshopnavigationpart' )}
    {include uri='design:parts/shop/menu.tpl'}
{/section}

{section show=eq( $navigation_part.identifier, 'ezusernavigationpart' )}
    {include uri='design:parts/user/menu.tpl'}
{/section}

{section show=eq( $navigation_part.identifier, 'ezvisualnavigationpart' )}
    {include uri='design:parts/visual/menu.tpl'}
{/section}

{section show=eq( $navigation_part.identifier, 'ezsetupnavigationpart' )}
    {include uri='design:parts/setup/menu.tpl'}
{/section}

{section show=eq( $navigation_part.identifier, 'ezmynavigationpart' )}
    {include uri='design:parts/my/menu.tpl'}
{/section}

{/section}

</div>
</div>

<hr class="hide" />

{/section}

What I need is something like this:

{section show=and( eq( $ui_context, 'edit' ), eq( $ui_component, 'content' ) )}
{section-else}

{section show=eq( $navigation_part.identifier, 'ezmynavigationpart' )}
    {include uri='design:parts/my/menu.tpl'}
{/section}

{/section}

The problem is that this won't display the menu, but if I put this in my pagelayout.tpl:

{include uri='design:parts/my/menu.tpl'}

The menu shows up but it is on every page and it makes no difference if I'm logged in or not.

I beleve the answer lies in the ui_context and ui_component, I have read the doc on these but it makes little sence to me:
http://ez.no/download/changelogs/ez_publish_3_5/ui_context_variables

Does anyone have any idea how I can get this working? Any help is very appreciated.

Cheers!

Pardon me while I burst into flames...

Mark Marsiglio

Saturday 26 November 2005 6:48:51 am

There are some built in user modules that might accomplish what you need...

http://yourdomain.com/notification/settings
http://yourdomain.com/content/draft
http://yourdomain.com/content/pendinglist
http://yourdomain.com/content/bookmark
http://yourdomain.com/collaboration/view/summary
http://yourdomain.com/user/password
http://yourdomain.com/shop/basket
http://yourdomain.com/shop/wishlist

You can create manual links to these modules from your "user account" section, and they will have access to the same modules that you can get in the admin.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Nathan Kelly

Sunday 27 November 2005 2:37:42 pm

Thanks Mark, I'll look into these, I have already set up a couple of manual links, the main issue is showing the menu in the right locations though.

I don't want the menu to be present on every page, only the pages that relate to the user account. Do you have any ideas how I might accomplish this?

Cheers!

Pardon me while I burst into flames...

Nathan Kelly

Monday 28 November 2005 6:53:09 pm

Ok I solved it, I thought the answer was in this doc:
http://ez.no/download/changelogs/ez_publish_3_5/ui_context_variables
And it was. The ui_context and ui_component variable were the key.

My code:

{def $this_user=fetch('user','current_user')}
{if $this_user.is_logged_in}

{def 
	$acc1=and($ui_component|eq('user'), $ui_context|eq('edit') ) 
	$acc2=and($ui_component|eq('content'), $ui_context|eq('edit') ) 
	$acc3=$ui_component|eq('notification')
}

{if or( $acc1, $acc2, $acc3 ) }
	
					<ul>
						<li><a{if $acc1} class="current"{/if} href={concat('/user/edit/', $this_user.contentobject_id)|ezurl}>{'My Account Details'|i18n("design/ccts")}</a></li>
						<li><a{if $acc2} class="current"{/if} href={concat('/content/edit/', $this_user.contentobject_id)|ezurl}>{'Change Account Details'|i18n("design/ccts")}</a></li>
						<li><a{if $acc3} class="current"{/if} href={'/notification/settings/'|ezurl}>{'My Notification Settings'|i18n("design/ccts")}</a></li>
					</ul>

{else}
{* context and component don't match so don't show the menu *}
{/if}

{undef $acc1 $acc2 $acc3}

{else}
{* this user is not logged in so don't show them anything at all *}
{/if}
{undef $this_user}

I know there may be a cleaner way to do this, but it works for now, if anyone has any ideas how I might simplify this code please make a suggestion.

Cheers!

Pardon me while I burst into flames...

esperion H

Tuesday 14 February 2006 12:17:43 pm

Hi Nathan,

Did you only use the code in your last post in the end?

Did you put it in pagelayout.tpl? Did you use it as is?

Regards Esperion

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.