Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request: log in / log out in theme menu #25

Closed
Japhys opened this issue Dec 23, 2020 · 5 comments
Closed

request: log in / log out in theme menu #25

Japhys opened this issue Dec 23, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@Japhys
Copy link

Japhys commented Dec 23, 2020

I would love to see something like this in the theme if login plugin is enabled.

{% if config.plugins.login.enabled and grav.user.username %}
    <li><i class="fa fa-lock"></i> {% include 'partials/login-status.html.twig' %}</li>
{% endif %}

However this code only shows Name, logout. I would like to see Login as a permanent menu item, which is replaced by Name, Logout once logged in. Basic behavior people would expect. Somehow I can't get this to work :(

@ParitoshBh ParitoshBh self-assigned this Dec 23, 2020
@ParitoshBh ParitoshBh added the enhancement New feature or request label Dec 23, 2020
@ParitoshBh
Copy link
Owner

There's a couple of different things that'll have to be addresses here,

  1. Navbar menu item -> Easy part. Although I do want to know the use case here.
  2. /login url -> Currently works but the form on page is sort of broken. It works but CSS needs fixing.

It'd be nice to know what you're trying to achieve here (besides showing login url/status in navbar) and how that can be useful for others. Reason I am asking this is I personally don't see the value in it (my preference is using admin dashboard) however if there's a strong use case here, I'll consider this!

@Japhys
Copy link
Author

Japhys commented Dec 26, 2020

I use my website as a personal 'Instagram' and for travel updates (pre and post covid of course). Mainly for friends and family. Others don't need to see where I am or what I do, they don't need to know these pages even exist.

So when people visit my website they only see two menu item: about and login. After logging in they see a couple more: photos and travel. That's the idea. And it already works like that.

I use /userlogin now and I put it in the menu, however the nav item name is not conditional. It remains whatever I call it, in this case login, even when you are logged in. I would like to see it change to log out after logging in,

This is probably not something you will have to implement in the theme, maybe something I'll have to figure out myself and put in my navigation twig. I just don't know how, can't get it to work :)

@ParitoshBh
Copy link
Owner

Pushed a new update 0.1.8, that should support your use case. If you're interested in code, here's the relevant portion 96a178f#diff-5c36d298048f0d5b0fb77402283f1c1bf4184911555dc8a92818aac4d79792f2

@Japhys
Copy link
Author

Japhys commented Dec 27, 2020

Wonderful! Thanks so much

edit

@ParitoshBh just to let you know I tried it and it worked exactly as I was hoping for. Many thanks!

@ParitoshBh
Copy link
Owner

Good to know it worked out for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants