ParitoshBh / grav-coder

https://paritoshbh.me
MIT License
28 stars 8 forks source link

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

Closed Japhys closed 3 years ago

Japhys commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Pushed a new update 0.1.8, that should support your use case. If you're interested in code, here's the relevant portion https://github.com/ParitoshBh/grav-coder/commit/96a178f2f55cf99d32b226729580dc80e2507ba2#diff-5c36d298048f0d5b0fb77402283f1c1bf4184911555dc8a92818aac4d79792f2

Japhys commented 3 years ago

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 commented 3 years ago

Good to know it worked out for you!