Welcome Guest, Not a member yet? Register   Sign In
Not sure how to approach this problem - Styling a login screen based on a url segment.
#1

[eluser]rreynier[/eluser]
I am trying to build a login system that is customized for the school you are trying to log in for.

Originally I was going to just have students go to app.site.com/login, this would be easy, but the styles for that school wouldn't be applied until after the student logged in and the appropriate school they are assigned to was pulled up from the database.

The problem is.. the login screen would be generic for everyone. What I was thinking was doing something along the lines of app.site.com/schoolname/function/fuction . Would I go about this using some sort of routing scheme? So by default the first segment signifies the school so I can pull up this information.

Any pointers / ideas would be welcome!
#2

[eluser]Josh Holloway[/eluser]
you could have the controller setup with some code like:

Code:
function index() {
    $school = $this->uri->segment(2);

    if ( $school == 'myschool' ) {
        $data['stylesheet'] = 'styles_myschool.css';
    }
    
    $this->load->view('login', $data);
}
with the view containing:
Code:
<link type="text/css" rel="stylesheet" href="path_to_css/<?= $stylesheet;?>"/>

or without controller interaction (not recommended as removes the point of having MVC):

Code:
<?php if ( $this->uri->segment(2) == 'myschool_1') :?>
<link type="text/css" rel="stylesheet" href="path_to_css/myschool_1.css"/>
<?php elseif ( $this->uri->segment(2) == 'myschool_1') :?>
<link type="text/css" rel="stylesheet" href="path_to_css/myschool_2.css"/>
<?php else :?>
<link type="text/css" rel="stylesheet" href="path_to_css/myschool_generic.css"/>
<?php endif;?>




Theme © iAndrew 2016 - Forum software by © MyBB