Login + User Self-Register integration?

Creating and modifying plugins.
Post Reply
sl4ppy
Regular
Posts: 5
Joined: Tue Mar 13, 2007 6:40 pm

Login + User Self-Register integration?

Post by sl4ppy »

I'm looking for a way to hide the User self-registration sidebar plugin if a user has already logged in via the Login sidebar plugin.

Essentially, I'd like to only show the Login plugin and the option to register via the User self-registration would be a simple 'register' link within the Login plugin.

Is the feasible?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Login + User Self-Register integration?

Post by garvinhicking »

Hi!

You could do that with some PHP code and tamper with the plugin files, but it would be nicer to do that with some Smarty magic.

Edit the 'sidebar.tpl' file of your template (copy it from templates/default/ into your template folder, if you don't have that file).

Inside the file you see something like:

Code: Select all

...
{foreach from=$plugindata item=item}
    <div class="serendipitySideBarItem container_{$item.class}">
        {if $item.title != ""}<h3 class="serendipitySideBarTitle {$item.class}"
        <div class="serendipitySideBarContent">{$item.content}</div>
    </div>
{/foreach}
....
This is the code responsible for each sidebar plugin. Now we add a IF-check to suppress a plugin in some case:

Code: Select all

...
{foreach from=$plugindata item=item}
  {if $item.class == 'serendipity_plugin_adduser' AND $is_logged_in}
  <!-- void, do nothing -->
  {else}
    <div class="serendipitySideBarItem container_{$item.class}">
        {if $item.title != ""}<h3 class="serendipitySideBarTitle {$item.class}"
        <div class="serendipitySideBarContent">{$item.content}</div>
    </div>
  {/if}
{/foreach}
....
Now, when the registration form shall be emitted, but the user is logged in, nothing will be shown there. Only in all other cases, the sdiebar plugin will be shown.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
sl4ppy
Regular
Posts: 5
Joined: Tue Mar 13, 2007 6:40 pm

Post by sl4ppy »

Wow, thats cool.. I had never messed with the sidebar.tpl before. Thanks for the thorough explanation too. :)

Hmm.. now my mind is spinning with idea's for modifying the sidebar.tpl even more.

Thanks a bunch!
sl4ppy
Regular
Posts: 5
Joined: Tue Mar 13, 2007 6:40 pm

Post by sl4ppy »

Is it possible for one plugin to hide/show another plugin?

For instance, say I modified the login plugin so that it has a register link. When that link is selected, only then is the adduser plugin shown.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
sl4ppy wrote:Is it possible for one plugin to hide/show another plugin?

For instance, say I modified the login plugin so that it has a register link. When that link is selected, only then is the adduser plugin shown.
You could try to do that by using the URL. If you check the $smarty.server.REQUEST_URI variable, you can see if that is like "/index.php?/register.html" (or whatever your link points to), and if that is the case, hide a specific plugin.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply