Welcome Guest, Not a member yet? Register   Sign In
Caching with logged in/not logged in or ecommerce basket views (idea for solution?)
#1

[eluser]surfgatinho[/eluser]
I really want to use some caching as the app I am building is getting fairly complicated with lots of queries and lots of joins.

Anyway, the problem is there is a user menu if they are logged in or a login box if they are not. CI caching doesn't deal with that, it just cache's the whole page.

A possible solution, which I am about to try in a minute would be to use javascript/ajax to spit out the login box / user menu.

It's not even going to impact on SEO because it's not really somewhere you want the search engines to be going.

I'll let you know how I get on
#2

[eluser]surfgatinho[/eluser]
Yep, works a treat!

Put a bit of jQuery ajax in the header to call a menu controller
Code:
[removed]
$(document).ready(function(){
       $.ajax({
           url: "<?=base_url();?>menu/index",
           global: false,
           type: "POST",
           async: false,
           dataType: "html",
           data: "",
           success: function (response)
                       {

                    $("#userMenu").append(response);
                   }
                  
          });
       });
    [removed]

Menu controller just chooses which view to load depending on user status:
Code:
<?php
class Menu extends Controller {
    
    function Menu()
    {
         parent::Controller();
        
    }
    
    function index()
    {
        
        if($this->freakauth_light->isValidUser()){ // are they logged in??
        $this->load->view($this->config->item('FAL_template_dir').'template/user_menu_in');
    }
    else{
        $this->load->view($this->config->item('FAL_template_dir').'template/user_menu_out');
    }

  }
}
?>
#3

[eluser]Unknown[/eluser]
That's may be not good, but I'll try. Thanks




Theme © iAndrew 2016 - Forum software by © MyBB