[support] Dynamically display menu items?

toon severijns toon.severijns at gmail.com
Tue Jun 7 20:40:44 UTC 2011


Joel, thanks for all the help. My view already works fine. I get an empty
result if there was no project flagged bu the user, but the corresponding
menu item is still displayed. I think i'm missing something. I don't see
what you mean by:

"If there is no project for that user, then the View doesn't fire, so you
create the menu in Empty Text area.  So one menu could be in Global:custom
text, and the other in Empty Text."

Thanks again!


Toon

On Tue, Jun 7, 2011 at 10:12 PM, Joel Willers <joel.willers at sigler.com>wrote:

> In relationships for Flags, you can have it 'Marked by current user'.  Then
> in Filters you can use that relationship for 'Flag: marked XXX'.
>
> If they haven't marked it, it won't show.
>
> Hope that helps.
>
> Joel
>
>
> Actually, to make it a bit more complex: there is no user reference field.
> The project is flagged by a certain user. This is used in the view
> "my_projects" as a relationship "Flags: student_selected by current user".
> Is there a way to still do what you described below? The only arguments
> that seem to be available to add are "Flags: Content ID" and "Flags: Flagged
> time".
> Or do i somehow have to create the user reference when flagging (through
> Rules)?
>
> Thank you so much for your help already!
>
> Best,
>
>
> Toon
> On Tue, Jun 7, 2011 at 8:59 PM, Joel Willers <joel.willers at sigler.com>
> wrote:
> For your PHP suggestion, you would use global $user and detect the user
> role, but you wouldn't be able to easily use this for detecting if they have
> a project.
>
> For my suggestion, you can use the content type Project (I don't know your
> configuration, so I'm making some general assumptions), and let's say it has
> a user reference called field_project_user.  You would set that as an
> argument, and in the section for what to do if there is no argument, you set
> a default argument as logged in user.  Then you set a filter for node:type =
> Project.
>
> If there is no project for that user, then the View doesn't fire, so you
> create the menu in Empty Text area.  So one menu could be in Global:custom
> text, and the other in Empty Text.
>
> Similar arguments can be used for many user fields, so play around with
> them.  If you give me more specifics, I might be able to send you more
> explanation, but really, that should be enough for you to create it.
>
> Joel
>
>
> Hey Joel, thank you so much!
> I think i could do it if i would be able to load the currently logged in
> user in the "Show if the following PHP code returns TRUE" box of the menu
> block. Can i do that? How?
>
> Alternatively, could you elaborate a bit on your last suggestion please?
>
> Best,
>
> Toon
>
> If it were me, I'd use Views and detect the User based on role and probably
> use Custom Field module for PHP and do all sorts of tests in there.  Since
> it's a block, though, arguments aren't passed, so you could do a Default
> argument from PHP and do all sorts of fun PHP code in there, so you wouldn't
> need an additional module.
>
> Or you could assign a role using a Rule, or have the User based on an
> argument (again, default argument, Current Logged in User), and use Empty
> Text to show a different menu based on the existence of that project.
>
> Actually, I kinda like that last idea...
>
> Joel
>
> You could make two blocks, put them in the same place and assign visibility
> settings based on role.  There are many options, though.
>
> Joel
>
> Hello all,
>
> Let's i want to display or not display a menu item depending on some
> property of the logged in user. E.g. when my user has selected a project
> (i.e. a reference to the project can be found through the user) i want to
> display a menu item "my project", if not i want to display a different menu
> item "available projects". How do i do this? Context? Rules? Menu hooks?
>
> Any ideas?
>
> Best,
>
>
> Toon
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20110607/58c0ca7f/attachment.html 


More information about the support mailing list