How to add login to homepage?

edited October 2011 in News & Announcements
Hi, I am new to Fuel and I see the dashboard forces a login but what about have the homepage having a login button and popup like it does for the dashboard? I know I can redirect with the new variable after login but I am completely confused as to how to do this.

Thanks.

Comments

  • edited 1:39PM
    What I am trying to do is have people log in from the homepage and then have code to determine what modules they have access to. Then only showing those links to those modules. Maybe that makes more sense. This is very new to me and I am more than a bit confused. I have done a lot of PHP but not MVC and not Fuel. Help if you would. I likely will be on here a lot until I can wrap my head around this. For some reason it is not making a lot of sense to me.
  • edited 1:39PM
    You can add a link to your homepage of mysite.com/fuel/login. With regards to "I know I can redirect with the new variable after login but I am completely confused as to how to do this."... can you clarify what you meant by the "new variable" part?
  • edited 1:39PM
    Thanks. i want it to instantly pop up with a log in if they are not logged in. So does your answer still apply the same? So they would come to the homepage and it would show the login if not logged in , and then send to the home of the application.

    The other variable was the login_redirect or something like that. So after they login takes them to whatever page that constant is set to. Constant, variable, whatever it is you added in recently.

    Ultimately, I need to make an application that loads in different modules with ajax into a div so the outside menu does not change. I can handcode all this but using MVC is a bit new to me so trying to figure out if I need an advanced module or just a regular module setup. I was thinking to keep the same url and somehow getting the inner div to ajax in new data. This is somewhat I new topic but thought I would ask why the author is helping. :o)
  • edited 1:39PM
    You would need to put some code on the homepage (perhaps in the view file or a controller) that would detect if the user is logged in. To do that you can use the fuel_helper function is_fuelified(). If the user is not logged in, then you could display the modal popup window that could have a username and password field that submit to the fuel/login page. You could then change the login_redirect value to be the 'home' page which would redirect you back to the homepage but hopefully logged in at that point.

    With regards to you wanting to load in different modules with ajax, that's a bit tougher to answer without some more details.
  • edited 1:39PM
    Thank you for the info on the login.

    OK, so as for the application. I need menu buttons at the top of the page, that will load in a different menu bar and content below that. The content may be different lists from a database along with its own particular toolbar for tools related to that particular list of items.
  • edited 1:39PM
    You should be able to use CodeIgniters MVC structure to build what you need. I think it may be good to read the documentation from CodeIgniter to help get you started:
    http://codeigniter.com/user_guide/general/controllers.html
    http://codeigniter.com/user_guide/general/views.html
    http://codeigniter.com/user_guide/general/models.html

    FUEL does have an extension of CI's models and it's documentation can be found here:
    http://www.getfuelcms.com/user_guide/libraries/my_model
  • edited 1:39PM
    Thanks. Ya I have done a lot of programming but this is just not coming easy to me. I understand the MVC, but having a tough time with this CMS even though I know it should be easy. I believe you are right. I need to read up more. I see a lot of people on here doing a lot of great things but no code posted very much and I really need examples. I don't see any ajax examples here on the forums. I mean, I have done a lot of ajax but nothing in MVC and I know it is a much different world. Thanks for giving it a go. I thought Fuel would be better to use than straight Codeignitor. Am I right or wrong that starting with a CMS is better than from nothing?

    Thanks.
  • edited 1:39PM
    You should be able to create methods on your controllers that you can use for ajax just like any other page. Additionally, FUEL has an is_ajax() function you can use to test if the request is an ajax request or not.

    With regards to using FUEL instead of straight up with a straight CodeIgniter install, you do get the ability to use CodeIgniter as intended, plus the addition of the CMS, the opt-in controller method and the ability to create modules which can be very helpful for most projects.
  • edited 1:39PM
    HI, thanks. I am trying to create a controller now. I can't find any examples of how to use one with this CMS. I know, I am so lame. I actually have a lot of experience but this MVC and CMS is still getting to me. I really don't know why but it is not becoming any clearer. I need someone to clear it up for me. I make a controller, but how do I output to a module in this CMS? I made a clients.php view and controller, and put this in the controller.. $this->load->view('clients'); but it gives me an major error. How do I call a vie file in this CMS from the controller? I see some render, output, and such and Codeignitor loads in a view with the code above. How about this CMS? Sorry, I hate being a lamo but I actually am not really this dumb, it just looks that way.
  • edited 1:39PM
    Just a note this worked in the controller:
    $this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'clients'));
    // $this->fuel_page->add_variables($vars);
    $this->fuel_page->render();

    But this did not.
    $this->load->view('clients');

    I read here http://www.getfuelcms.com/forums/discussion/comment/1818/#Comment_1818 that $this->load->view('clients'); should have worked. I am glad something works for me, but why did it not work when it appeared it should have with CI way?

    Thanks...
  • edited 1:39PM
    I wanted to note something as I am learning. This line $CI =& get_instance(); in the global file does not hold in a controller file. You mention it should not be needed if set in the globals but I see it in some of your model examples. I am assuming when the controller is started it has not gotten the global variables yet. Just a thought on top of all the others. Once I start understanding I move fast. Right now, am still slow but getting there. I watched some more videos on CI and also started understanding the differences between the base CI and your addon and how great your CMS is as it saves a lot of time, or can.
Sign In or Register to comment.