Shouldnt login button text change once the user logs in?

Feel free to talk about everything related to our Joomla Products
Rate this topic: Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.
GK User
Tue Jul 22, 2014 5:42 am
Hello guys,


I am using simplicity and i wonder, shouldn't the login button test change to something like "logout" after the user logs in?
User avatar
Expert Boarder

GK User
Sat Jul 26, 2014 2:09 pm
Hello,

In this template this feature is not available by default, but you can implement it as we have implemented it i.e. in the University template - please open file lib/menu/GKBase.class.php and in method genMenuItem please add after line:

Code: Select all
$txt .= $tmpname;


please add the following fragment:

Code: Select all
if(stripos($active, 'gkLogin') !== FALSE) {
            $user = JFactory::getUser();
            if($user->id > 0) {
               $txt = JText::_('TPL_GK_LANG_MYACCOUNT');
            }
         }


It will replace the text in the menu item which has CSS class "gkLogin".

Of course you have to add in the template language file the following phrase:

Code: Select all
TPL_GK_LANG_MYACCOUNT="My account"
User avatar
Administrator

GK User
Sat Aug 09, 2014 8:03 pm
dziudek wrote:Hello,

In this template this feature is not available by default, but you can implement it as we have implemented it i.e. in the University template - please open file lib/menu/GKBase.class.php and in method genMenuItem please add after line:

Code: Select all
$txt .= $tmpname;


please add the following fragment:

Code: Select all
if(stripos($active, 'gkLogin') !== FALSE) {
            $user = JFactory::getUser();
            if($user->id > 0) {
               $txt = JText::_('TPL_GK_LANG_MYACCOUNT');
            }
         }


It will replace the text in the menu item which has CSS class "gkLogin".

Of course you have to add in the template language file the following phrase:

Code: Select all
TPL_GK_LANG_MYACCOUNT="My account"



Hi,


Unfortuntely it didn t work. :(
I did everything step by step....
User avatar
Expert Boarder

GK User
Sun Aug 10, 2014 7:56 am
Please send me your modified file.
User avatar
Administrator

GK User
Sun Aug 10, 2014 2:44 pm
dziudek wrote:Please send me your modified file.


Just sent you a pm with a link, to download the files.
/
Thanks for looking into this
User avatar
Expert Boarder

GK User
Mon Aug 11, 2014 6:50 am
The code seems to be ok - do you have a gkLogin CSS class in this menu item?
User avatar
Administrator

GK User
Mon Aug 11, 2014 1:26 pm
dziudek wrote:The code seems to be ok - do you have a gkLogin CSS class in this menu item?



Yes.... :(
User avatar
Expert Boarder

GK User
Mon Aug 11, 2014 6:40 pm
Could you please provide me with a URL to your website and FTP access via PM (click the “Private Message” text underneath my avatar) so that I may analyze it?
User avatar
Administrator

GK User
Mon Aug 11, 2014 11:10 pm
dziudek wrote:Could you please provide me with a URL to your website and FTP access via PM (click the “Private Message” text underneath my avatar) so that I may analyze it?


I just sent you a pm.
Thank you for the help.
User avatar
Expert Boarder

GK User
Tue Aug 12, 2014 7:21 am
Your problem is caused by fact that your log in item is not located in the mainmenu - my custom change was dedicated for main menu. In your case (log in item in custom menu) I have no solution.
User avatar
Administrator

GK User
Tue Aug 12, 2014 4:00 pm
dziudek wrote:Your problem is caused by fact that your log in item is not located in the mainmenu - my custom change was dedicated for main menu. In your case (log in item in custom menu) I have no solution.



Thank you for your efforts.

Bare with me just in case you are still willing to waste a few minutes thinking on this.. .. Would it be possible to have a module or menu link only only visible to logged in users?
User avatar
Expert Boarder

GK User
Thu Aug 14, 2014 9:06 pm
If you want to display some code visible for the registered users you have to wrap your code into the following code:

Code: Select all
$user = JFactory::getUser();
if($user->id > 0) {
// code to display for the registered users
}
User avatar
Administrator

GK User
Thu Aug 14, 2014 10:43 pm
dziudek wrote:If you want to display some code visible for the registered users you have to wrap your code into the following code:

Code: Select all
$user = JFactory::getUser();
if($user->id > 0) {
// code to display for the registered users
}



then i guess that using
Code: Select all
$user = JFactory::getUser();
if($user->id = 0) {
// code to display for the registered users
}


Would only show to not loged in users?

This could mean i could create 2 custom buttons to be my login and logout button and wrap them with the code above? (instead of using a joomla menu).
User avatar
Expert Boarder

GK User
Fri Aug 15, 2014 11:33 am
Yes, but please use the following line for the not-logged users:

Code: Select all
if($user->id == 0) {


condition:

Code: Select all
if($user->id = 0) {


is always true - even if $user->id is different than 0.
User avatar
Administrator

GK User
Fri Aug 15, 2014 2:17 pm
dziudek wrote:Yes, but please use the following line for the not-logged users:

Code: Select all
if($user->id == 0) {


condition:

Code: Select all
if($user->id = 0) {


is always true - even if $user->id is different than 0.


Thanks!!
I will try this on the weekend and update the topic.


Maty i suggest for this to be a sticky topic or your guys making a Blog post about this?
I am guessing allot of peeps out there would be interested.
User avatar
Expert Boarder

GK User
Sat Aug 16, 2014 7:26 pm
I'll ask one of our developers to write this kind of article soon :)
User avatar
Administrator

GK User
Wed Sep 10, 2014 1:59 pm
Just noticed i never updated the topic.
So, .. here goes.

I confirm it works like a charm.
User avatar
Expert Boarder


cron