Jump to content

Using a css file with MVC


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
https://forums.phpfreaks.com/topic/284269-using-a-css-file-with-mvc/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.