Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Thanks for this little module :)
Is there a simple way to display a Logout link, where the Login link was, when users are logged in?
I thought maybe I could pop in something like the below on about line 44 of
login_popup/src/Plugin/Block/LoginAndRegisterPopup.php
if (\Drupal::currentUser()->isAuthenticated()) { ?>
<a href="user/logout">Log out</a>
<?php }
or possibly
else { ?> <a href="user/logout">Log out</a>
<?php }
both of which seem to work straight after clearing cache but not after that...
Sorry for my complete ignorance of php - Hopefully this is an easy one to solve!?
Comment | File | Size | Author |
---|---|---|---|
#11 | show_logout_links_updated-2913332-11.patch | 12.4 KB | akshay_d |
Comments
Comment #2
Bala.addweb CreditAttribution: Bala.addweb at AddWeb Solution Pvt. Ltd. commentedPFA Patch.
Comment #3
Subhransu.addweb CreditAttribution: Subhransu.addweb at AddWeb Solution Pvt. Ltd. commentedI Applied the patch and having warning: "warning: 1 line adds whitespace errors."
>> Above patch provides logout button only for login & register block. So, I add logout link in login block and register block separately.
PFA new patch for the same.
Thanks!
Comment #4
JayKandariWe would need to create a configuration on the blocks itself say a checkbox "Show Logout Link" which will be unchecked by default, When that configuration is checked, then only we show the Logout links.
We would need this for sites which have already implemented this module, so that they don't accidentally see the Logout Links.
Comment #5
akshay_dComment #6
akshay_dHi @JayKandari
Updated the login_popup to have the logout link based on the requirement. also i have fixed the phpcs for the module.
please review the code.
Comment #7
JayKandariThank you @akshay_d for the review.. I have added few feedbacks.
Can you please take a look at them for each of the blocks.
Instead of checking `isset()` can we check `!empty()` ?
Can we also implement the defaultConfiguration() method?
Instead of `global $base_url;` can we use `\Drupal::request()->getSchemeAndHttpHost();` something like this?
Comment #8
akshay_dHi @JayKandari
Updated the patch according to the suggestion please review.
Thanks
Comment #9
akshay_dPlease ignore the previous patch and consider this patch
Thanks
Comment #10
JayKandariThank you @akshay_d... Looks good. below 2 minor comments if you can address.
Thanks !!
Can the default value be either 0 or FALSE?
Can we remove `$request->getBasePath()` section because `$request->getSchemeAndHttpHost()` will generate value like this eg: https://www.example.com/ which is what we require right?
Comment #11
akshay_dUpdated all the mentioned changes in one patch
please check
Thanks @JayKandari :)
Comment #13
JayKandariThanks @akshay_d. Patch Looks good. Commited & Pushed to 2.x branch
Thanks !!