Customer Portal

Get Involved. Join the Conversation.

Topic

    DustinTuft
    Change home page based on SLA issued
    Topic posted February 25, 2009 by DustinTuft Bronze Medal: 1,250+ Points, last edited October 29, 2011 
    1233 Views, 5 Comments
    Title:
    Change home page based on SLA issued
    Content:

    Hi,

     

    I am tring to find out how to redirect a customer to a particulare home page based on that users SLA ellections. I have created a model to idenify the SLA level, as we have a rather complex matrix of SLA's it's possible for the user to have more then one type of SLA. The model returns a single word that defines the level, now how do I redirect at the controller or view level once I have identified that a user should be directed to an alternat home page?

     

    Thanks

    Comment

     

    • Leif Wickland
      Dustin,

      It sounds like you want to send an HTTP redirect header based on the SLA model. Potentially the best route to go is to add another method to your SLA model that translates the SLA level into the correct home page.

      Then you could change the home.php to consist of only something like:

      <?php

      $this->load->model('custom/Sla_model');

      $newUrl = $this->Sla_model->getHomePageUrl() . sessionParm();

      header("Location: $newUrl");

      exit("Redirecting to $newUrl...");

      ?>

      <html><head></head><body></body></html>

      You probably wouldn't want this page to have a template.  The minimal HTML document is required to satisfy our the deploy process.  The sessionParm() is recommended to ensure that you are not double billed for requests if visitors have cookies turned off.

       

      This seemed to work in the quick test that I ran.

       

      Additionally, you'll probably want to make sure that you have the

      <rn:meta clickstream='home'/>

       

      tag in your alternate home pages so that stats are collected correctly. 

       

      Please let me know how this works.

       

      Thanks,

       

      Leif Wickland

      Software Developer

    • DustinTuft

      So just so I understand, I need to have my home page be blank, and use the model to decide where to redirect to? So even my current defualt not logged in page would be part of the model return to routing code?

       

      Thanks

    • Leif Wickland
      Dustin,

      It wouldn't be required to have /app/home produce a redirect for not-logged-in users. If you wanted to serve a page to those users without a redirect, you'd need /app/home to not use a template or move the redirect logic to the top of its template and only redirect conditionally if the page being served was the home page.

      Leif


    • DustinTuft

      That makes since, I have not yet attempted to idnetify what page is being servered, is there an object that tells me where I am at?

       

      Thanks

    • Leif Wickland
      Dustin,

      In a page, you should be able to use $this->page to get "home" or the like. (Donning lawyer cap...) Admittedly, that's undocumented, so it could potentially change.

      Alternatively, you could use the $_SERVER['REQUEST_URI'] to get the URL as requested by the browser. That is documented although more complicated. You could also use $this->uri->segment(3), which is a built in part of CodeIgniter.

      Leif