Get login link in module code

memgir

Joined: 2011-04-05
Posts: 11
Posted: Wed, 2013-05-29 18:48

Hi,

I'd like to use the login link in the comment module's code so that when a user is not logged in and this is mentioned to the user, a link is also given in that sentence. I changed the code appropriately but don't know how to generate the link via php code.

Thanks in advance!

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2013-05-29 22:19

You can set permissions for comments not show for guests. But I digress....This is what you want to add:

<? $user = identity::active_user();
    if ($user->guest) : ?>
        <?= t("Translatable text ") ?><a id="g-user-profile-link" class="g-dialog-link " href="<?= url::site("login/ajax") ?>"><?= t("Login") ?></a>
    <? endif ?>

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
memgir

Joined: 2011-04-05
Posts: 11
Posted: Mon, 2013-06-03 12:21

Thank you for your answer dave. It worked but not exactly as I wanted it to be because of the openid module that I use. What your suggestion brings up is the classic login form. Openid module replaces some links automatically; Can't such a link be used instead of "login/ajax" so that when openid module is active, it takes you to openid login page and otherwise to the classical login page? Pretty much like the one in the top right login link of gallery (which exists at least in the theme clean canvas)?

 
memgir

Joined: 2011-04-05
Posts: 11
Posted: Mon, 2013-06-03 15:14

I tried entering "openid" instead of "login/ajax" in function site, and it opened up a complete gallery openid login page in the comments section -in contrast to showing only a username/password inputs with login/ajax. Perhaps it has to do with openid module code?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2013-06-03 16:54

I've never used the openID module if the url is different just change the code to reflect that or am I going to have to install the module to understand what you are asking as I don't understand now. Perhaps a url to your site witht he module in question and a temp username/password would help me understand.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
memgir

Joined: 2011-04-05
Posts: 11
Posted: Mon, 2013-06-10 12:10

I just sent you a pm with the link to the site.

Thank you for looking into this dave.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2013-06-11 02:31

Add:
<?= t("Translatable text ") ?><a id="g-user-profile-link" href="<?= url::site("openid") ?>"><?= t("Login") ?></a>
to modules/comment/views/connents.html.php just after:

<?php defined("SYSPATH") or die("No direct script access.") ?>
<? if (comment::can_comment()): ?>

The openid module does not have a referral url parameter that I can see so it does not redirect you back to the page you were on anyway.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team