adding a link

Questions and answers about change of functions, design, hosting etc.

Moderators: Koduc, Xpycm

Forum rules
Pay attention! Forum is not a means for guaranteed support of clients and users. An answer as well as a quick answer is not supposed on the forum. We post messages as soon as possible.

The message limit on the forum is 3 messages per day.
If you want to say "thank you" then use the function "Give good reputation point", which is a green icon "plus" under the nickname of the person, who answered the message.

adding a link

Postby zoom2 » 13 Jul 2014, 18:02

Hi,

I want to add" Login" and "Signup" link button in the main page. I tried this , but both links are coming in separate 2 lines. Refer attachment.
I wanted it be part of "User-panel" menu item.

I have edited code "protected/views/layout/main.php( refer attachment for code change)
Please guide me.
Attachments
login-2.jpg
code change
login-2.jpg (73.99 KiB) Viewed 22351 times
login_1.jpg
Link is coming in next line
login_1.jpg (129.13 KiB) Viewed 22351 times
zoom2
Stranger
 
Posts: 23
Joined: 07 Jul 2014, 07:41
Reputation point: 0

Re: adding a link

Postby zoom2 » 14 Jul 2014, 12:28

Hello,

Could you please help me in resolving the above issue.
It will be of great help.

Regards
Alva
zoom2
Stranger
 
Posts: 23
Joined: 07 Jul 2014, 07:41
Reputation point: 0

Re: adding a link

Postby zoom2 » 20 Jul 2014, 08:36

Hi,

Any help I can get on the above request from experts.

Thank you
Alva
zoom2
Stranger
 
Posts: 23
Joined: 07 Jul 2014, 07:41
Reputation point: 0

Re: adding a link

Postby Koduc » 21 Jul 2014, 06:51

Edit file /protected/components/Controller.php
Insert following code:
Code: Select all
            array('label' => '|''visible' => Yii::app()->user->getState('isAdmin') === null),
            array(
                
'label' => tc('Login'),
                
'url' => array('/site/login'),
                
'visible' => Yii::app()->user->getState('isAdmin') === null,
            ),
            array(
'label' => '|''visible' => Yii::app()->user->getState('isAdmin') === null),
            array(
                
'label' => tc('Register'),
                
'url' => array('/site/register'),
                
'visible' => Yii::app()->user->getState('isAdmin') === null,
            ), 

after:
Code: Select all
            array(
                
'label' => Yii::t('common''Control panel'),
                
'url' => array('/usercpanel/main/index'),
                
'visible' => Yii::app()->user->getState('isAdmin') === null,
                
'items' => $subItems,
                
'submenuOptions'=>array(
                    
'class'=>'sub_menu_dropdown'
                
),
            ), 
-- Меньше знаешь - крепче спишь --
User avatar
Koduc
Team lead
Team lead
 
Posts: 64
Joined: 28 Dec 2011, 09:11
Reputation point: 0

Re: adding a link

Postby zoom2 » 21 Jul 2014, 18:17

Dear Team,

Thank you for your continuous support.

After going through the forum, I observed that your team is providing great support to all users.
Keep up the good work!

Regards
Alva
zoom2
Stranger
 
Posts: 23
Joined: 07 Jul 2014, 07:41
Reputation point: 0

Re: adding a link

Postby zoom2 » 15 Nov 2014, 16:52

Hi,

I added extra "login" and "register" link in the home page as mentioned above. But it will be visible after the user login also. I want to hide once user logs in.
You mentioned to add following additional code "'visible' => !Yii::app()->user->isGuest,"

But not sure where to include I did like below, but did not work:

array(
'label' => tc('Login'),
'url' => array('/site/login'),
'visible' => !Yii::app()->user->isGuest,
'visible' => Yii::app()->user->getState('isAdmin') === null,
zoom2
Stranger
 
Posts: 23
Joined: 07 Jul 2014, 07:41
Reputation point: 0

Re: adding a link

Postby andipas » 18 Nov 2014, 10:36

Code: Select all
 
array(
                'label' => tc('Login'),
                'url' => array('/site/login'),
                'visible' => !Yii::app()->user->isGuest,
 


without 'visible' => Yii::app()->user->getState('isAdmin') === null,
andipas
Web Developer
Web Developer
 
Posts: 156
Joined: 28 Dec 2011, 22:37
Reputation point: 1

Re: adding a link

Postby zoom2 » 25 Nov 2014, 20:03

Hi,

As explained above I have added " 'visible' => !Yii::app()->user->isGuest," and commented "'visible' => Yii::app()->user->getState('isAdmin') === null,"
as shown below.

array(
'label' => tc('Login'),
'url' => array('/site/login'),
'visible' => !Yii::app()->user->isGuest,
// 'visible' => Yii::app()->user->getState('isAdmin') === null,

The result is :
1. Login link disappeared for guest and register link was available.
2. Also I observed after loging in still "login" and "register" link was available.

I required earlier to only display "login "and "register" link for guest and once user logs in then both link should not be available.

Please suggest solution.

Regards
Raj
zoom2
Stranger
 
Posts: 23
Joined: 07 Jul 2014, 07:41
Reputation point: 0

Re: adding a link

Postby Foton » 02 Dec 2014, 13:50

Try to use
Code: Select all
 'visible' => Yii::app()->user->isGuest
for both link
Foton
Web Developer
Web Developer
 
Posts: 117
Joined: 26 Jan 2012, 14:58
Reputation point: 1


Return to Questions and help for changes

Who is online

Users browsing this forum: No registered users and 2 guests

cron