Forums / Setup & design / [solved] My account menu for users (same as admin)

[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

eZ debug

Timing: Jan 19 2025 00:34:06
Script start
Timing: Jan 19 2025 00:34:06
Module start 'content'
Timing: Jan 19 2025 00:34:07
Module end 'content'
Timing: Jan 19 2025 00:34:07
Script end

Main resources:

Total runtime0.9186 sec
Peak memory usage4,096.0000 KB
Database Queries202

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 589.2891180.8125
Module start 'content' 0.00710.7610 770.1016623.3516
Module end 'content' 0.76810.1505 1,393.4531341.3672
Script end 0.9185  1,734.8203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.4566210.0002
Check MTime0.00160.1738210.0001
Mysql Total
Database connection0.00120.131210.0012
Mysqli_queries0.827490.07502020.0041
Looping result0.00270.28952000.0000
Template Total0.891397.020.4456
Template load0.00180.197720.0009
Template processing0.889596.826520.4447
Template load and register function0.00010.012110.0001
states
state_id_array0.00100.107910.0010
state_identifier_array0.00100.111820.0005
Override
Cache load0.00160.1752500.0000
Sytem overhead
Fetch class attribute can translate value0.00180.194040.0004
Fetch class attribute name0.00120.129870.0002
XML
Image XML parsing0.00130.146840.0003
class_abstraction
Instantiating content class attribute0.00000.001790.0000
General
dbfile0.00260.2778320.0001
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs