Page 1 of 1

FEU + custom login [possibly solved]

Posted: Thu Mar 24, 2011 10:57 pm
by samj
Solution ( from another post, and see below):
use in template file : {assign var='loggedin' value=$ccuser->loggedin()}
use in Content : {if $loggedin}
good luck;
----------------------------------------------------------------------
Goal: to have a custom login area for FEU in a menu template when the user is logged in, one area should show:
Welcome (name) Log out Register

When no user is logged in the same area should show:
You are not logged in Log in Register

The <div> containing the three elements is defined as a menu template (this might have something to do with the unexpected output). Right now it should render as one <li> item.

Code in "login" menu template:
(note: {FrontEndUsers form="logout"} should load the logout page of FEU, which only says "Logout" and when clicked logs out the User from here; but other options are welcome.
(note: for simplicity's sake, the "Register" link is omitted)

Code: Select all

{if $loggedin}<span class="welcome_prompt">Welcome, $username</span>
                    <span class="logout_button">{FrontEndUsers form="logout"}</span>

                   {else}<span class="">you are not logged in</span>
                   <span class="login_button"><a ref="{$url_logout}"
title="{$mod->Lang('info_logout')}">{$mod->Lang('logout')}</span> 
                     
{/if}  

I also tried <ul>s :
<ul>
{if $loggedin} <li><span class="welcome_prompt">
                           Welcome, $username</span>
                     </li>...etc
</ul>

or:

{if $loggedin}<ul> <li><span class="welcome_prompt">
                           Welcome, $username</span>
                     </li>...etc
</ul>

;syntax errors, smarty errors, logical errors; I probably have them all

As I was changing the code around, notices are popping up:
Notice: Undefined index: loggedin in C:\xampp\htdocs\mysite\tmp\templates_c\fbf09a8716c53a726a4842338b2fe125^%%80^800^8007C7A5%%module_db_tpl%3AMenuManager%3BNav_login.php on line

Every notice referrs to a /tmp location, such as the one above.
which file is it referring to? where is it located? what's an undefined index? where can I define it, and change it to what?


thanks

Re: FEU + custom login

Posted: Fri Mar 25, 2011 3:14 am
by jmcgin51
you need to read the module help files

where did you find the reference to {$loggedin}?? It is not a valid reference. Try {$ccuser->loggedin} instead. And make sure you don't use a WYSIWYG when you're using this reference, as a WYSIWYG will turn the > into an HTML entity and destroy your code.

Re: FEU + custom login

Posted: Fri Mar 25, 2011 4:40 am
by samj
Simply replacing "$loggedin" with "$ccuser->loggedin" does not work.
where did you find the reference to {$loggedin}??
in a post in csm forums (no, in one of the many, many post in the cms forum; I didn't just make it up)

I am not at the stage of custom code work yet. I am cutting and pasting from posts , tutorials, help files.

The logic goes this way: Is the present user logged in? if yes, display one line, if not, the other.
In "pig-latin" lingo: if ($user==loggedin) {......etc.} else {.....etc.}

or am I putting the cart before the horse with my approach.

thanks

Re: FEU + custom login

Posted: Fri Mar 25, 2011 1:17 pm
by jmcgin51
you do have CustomContent installed along with FEU, correct? CC is required to be able to protect content. FEU just handles the user authentication.

If you have both FEU and CC installed, then this will work:
{if $ccuser->loggedin()}
put your protected content here
{else}
put alternate content here, or a link to a login page
{/if}

Re: FEU + custom login

Posted: Fri Mar 25, 2011 5:47 pm
by samj
thanks jmcgin51
that is exactly the information I was looking for, the kind one does not find in the help files. No, I was not aware that cc is required, nor that the WYSIWYG breaks the code - both priceless pieces of info.

All I wanted to do is have the existing pre-configured logout screen, which in essence is just a "LOG OUT" -link (which is usually displayed in it's own window in the same area just like the much larger login screen) displayed in my short mini-menu instead of the default area: page{content} = no custom coding necessay, except for the most basic if-construct. Everything else, such as
"<a href="{$url_logout}" title="{$mod->Lang('info_logout')}">{$mod->Lang('logout')}</a>"
are copied and pasted from the existing FEU templates or other pieces of code.
At this point, without having any knowledge about cc, your suggestion seems to be able to do the trick.
I may certainly be wrong, but I still can not imagine a program like FEU, which authenticates users, does not have some form of "user-state inspection/verification." Such as : (in pig-latin code for logical demonstration): if ($user==logged_in){to this...} else {do that...}; if {loggedin==true}...
When logging in a second time as the same user, Feu tells me that I am already logged in ==> this suggests that somewhere within the code Feu must check somewhere if the present user is already logged in or not. So, my thinking was that, if I can find that line of code which verifies the user, and use the appropriate variable/state/flag.... from that location such as "$user" or "$loggedin==1", etc.., I could theoretically reuse already existing code snippets and data without reinventing the wheel, which I do not know how to do yet.
NOT knowing the code, nor knowing where to look, many basic questions may arise to a newbie, as simple as the variable name. Could it be $user, $user_name, Smarty.user, Smarty->user.logged_in ?,...since it all depends how the coder set everything up.)
But, I guess it is all just my faulty logic/assumption as a non-programmer; FEU may well be designed on purpose to utilize another module to accomplish what I would like to do.

Well, thanks for the info; will go away for now and study CC.

samj