0

I've been asked to create a member's area in the site I am currently constructing.

This area should be accessible via a menu section that should only appear to logged in users.

Furthermore, if the user's role is a specific one, the menu should have one extra entry in which the user (let's say he is a baker, and the site is about a pastry shop), can see his earnings in a calendar like mode, assuming each of the cakes sold give's him a percentage.

So all in all, we have very conditional menu items.

Furthermore, the /user page, if the user is logged in (if it's not it's just a themed version of the original Drupal /user page), should be a view, or Panel, or collection of View blocks, that should depict a summary of the 4 links that follow.

At the moment my /user page shows the default "History" and some other stuff some modules have added. How can this page be styled?

The other menu items are: Your Account, Your Cart, Wish List, Order History, pretty much self explanatory, and more or less accessible using Menu Tokens.

The menu's structure is something like this

-You (if user is logged in should change to his first name)
|-Your Account (should lead to a form just like user/register (already themed) where the user can edit his information)
|-Your Cart (commerce cart - kinda easy)
|-Wish List (commerce wishlist - easy too)
|-Order History (commerce orders - easy too)
|-Earnings (for 'Baker' role only)

So the /user page should show (in a different fashion of course) all this information condensed.

So, to recap, the difficulties I am facing are:

  1. Conditional name of the "You" item
  2. Conditional appearing of the 4 sub-items
  3. Conditional appearing ofthe 5th sub-item according to role
  4. Theming of the /user page (when logged-in) (fixed using panel with UID as argument)

Any help for any of those would be highly appreciated.

1 Answer 1

2

You should check out Context module, can solve your needs listed above.

One way you can do is to create different menus for different roles.

For example, you create a menu called 'menu for anonymous' , add links for anonymous in the menu; create another menu called 'menu for member', add particular links in the menu. and so forth.

With Context module, you can set 'menu for anonymous' to display for anonymous user; set 'menu for member' to display only for user has whatever role.

For changing 'You' to username, I am thinking that you can use hook_block_view_alter, loop to all menu items in the menu block, replace 'you' to user's name.

Again, with context module, you can add a section variable to the theme for the context of user logged in.

enter image description here

then you can customize your template in page--user.tpl.php

if (!empty($section_title)):
        ... theming for logged in user  ...
else:
    ... theming for general ...  
endif;

Hope my answer make sense.

6
  • makes sense, upvoted, still trying to tackle how to theme /user page though.
    – user5005
    Mar 27, 2012 at 13:05
  • using context, is there a way I can show portion of the menu or do you reckon I should add the whole menu in a rule?
    – user5005
    Mar 27, 2012 at 13:10
  • will you elaborate how you want to theme of /user page? context module also can set action on theme page/html.
    – gilzero
    Mar 27, 2012 at 13:13
  • expanded my answer for theming /user page for authenticated.
    – gilzero
    Mar 27, 2012 at 13:26
  • Drupal will hide inacessible menu items based on access permissions, so I'd play at that level first. Then, you can theme your page based on user_is_logged_in() result.
    – Countzero
    Mar 27, 2012 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.