Jump to content

Using a css file with MVC


mike12255
Go to solution Solved by mike12255,

Recommended Posts

So im still playing around with this MVC stuff think im starting to understand/get the hang of it! The issue im currently having is getting the CSS file to work! I have my header and footer in their own files so I call them both when I load pages. All three objects being called are supposed to be linked to: public/css/default.css. 

 

my header file looks like this:

<!doctype html>
<html>
<head>
    <title><?=(isset($this->title)) ? $this->title : 'MVC'; ?></title>
    <link rel="stylesheet" href="<?php echo URL; ?>public/css/default.css" />    
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/sunny/jquery-ui.css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
    <script type="text/javascript" src="<?php echo URL; ?>public/js/custom.js"></script>
    <?php 
    if (isset($this->js)) 
    {
        foreach ($this->js as $js)
        {
            echo '<script type="text/javascript" src="'.URL.'views/'.$js.'"></script>';
        }
    }
    ?>
</head>
<body>

<?php Session::init(); ?>
    
<div id="header">

    <?php if (Session::get('loggedIn') == false):?>
        <a href="<?php echo URL; ?>index">Index</a>
        <a href="<?php echo URL; ?>help">Help</a>
    <?php endif; ?>    
    <?php if (Session::get('loggedIn') == true):?>
        <a href="<?php echo URL; ?>dashboard">Dashboard</a>
        <a href="<?php echo URL; ?>note">Notes</a>
        
        <?php if (Session::get('role') == 'owner'):?>
        <a href="<?php echo URL; ?>user">Users</a>
        <?php endif; ?>
        
        <a href="<?php echo URL; ?>dashboard/logout">Logout</a>    
    <?php else: ?>
        <a href="<?php echo URL; ?>login">Login</a>
    <?php endif; ?>
</div>
    
<div id="content">
    
    

When I view page source it looks like this:


<!doctype html>
<html>
<head>
    <title>Login</title>
    <link rel="stylesheet" href="missednote.com/public/css/default.css" />    
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/sunny/jquery-ui.css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
    <script type="text/javascript" src="/public/js/custom.js"></script>
    </head>
<body>

    
<div id="header">

            <a href="/index">Index</a>
        <a href="/help">Help</a>
        
            <a href="/login">Login</a>
    </div>
    
<div id="content">
    
    <h1>Login</h1>

<form action="login/run" method="post">
    
    <label>Login</label><input type="text" name="login" /><br />
    <label>Password</label><input type="password" name="password" /><br />
    <label></label><input type="submit" />
</form></div>

<div id="footer">
    (C) Footer
</div>

</body>
</html>

I don't understand this maybe the htaccess file wont let it access the css file directory properly, could that be it? I am not familiar with the htaccess file and found one on the internet that I thought did what I wanted. 

 

A live version of my test can be seen at: http://www.missednote.com/login/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.