Page 1 of 1
Login + User Self-Register integration?
Posted: Tue Sep 11, 2007 2:04 am
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?
Re: Login + User Self-Register integration?
Posted: Tue Sep 11, 2007 11:35 am
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
Posted: Tue Sep 11, 2007 5:07 pm
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!
Posted: Wed Sep 12, 2007 1:43 am
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.
Posted: Wed Sep 12, 2007 12:33 pm
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