php – Error 404 in SASS

Question:

Hello. I went to install an Opencart module in a store version v1.5.6.4 and saw that the scss of this module is not being found (error 404) even though it is on the server and in the correct folder.

The header looks like this:

<?php if (isset($_SERVER['HTTP_USER_AGENT']) && !strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') && strpos($_SERVER['HTTP_USER_AGENT'], 'Opera')) echo '<?xml version="1.0" encoding="UTF-8"?>'. "\n" ."<!-- This is here for the Old Opera mobile  -->"; ?>
<!DOCTYPE html>
<!-- OMFramework 2.3.0 Basic www.omframework.com -->
<!--[if IEMobile 7 ]>    <html class="no-js iem7"> <![endif]-->
<!--[if (gt IEMobile 7)|!(IEMobile)]><!--> <html dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>"> <!--<![endif]-->
  <head>
    <meta charset="UTF-8" />
    <title><?php echo $title; ?></title>
    <base href="<?php echo $base; ?>" />

    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' name='viewport' />

    <?php if ($description) { ?>
    <meta name="description" content="<?php echo $description; ?>" />
    <?php } ?>
    <?php if ($keywords) { ?>
    <meta name="keywords" content="<?php echo $keywords; ?>" />
    <?php } ?>
    <?php if ($icon) { ?>
    <link href="<?php echo $icon; ?>" />
    <?php } ?>
    <?php foreach ($links as $link) { ?>
    <link href="<?php echo $link['href']; ?>" />
    <?php } ?>
    <?php if (file_exists(DIR_TEMPLATE . $this->config->get('config_mobile_theme') . '/stylesheet/mobile2.scss')) { ?>
    <link type="text/css" href="<?php echo 'catalog/view/theme/' . $this->config->get('config_mobile_theme') ?>/s.php?p=mobile2.scss" >
    <?php } else { ?>
    <link type="text/css" href="catalog/view/theme/omf2/s.php?p=mobile2.scss" >
    <?php } ?>
    <?php foreach ($styles as $style) { ?>
    <link type="text/css" href="<?php echo $style['href']; ?>" media="<?php echo $style['media']; ?>" />
    <?php } ?>
    <script>
        document.cookie='resolution='+Math.max(screen.width,screen.height)+'; path=/';
        setTimeout(scrollTo, 0, 0, 1);
        (function(w,d,u){w.readyQ=[];w.bindReadyQ=[];function p(x,y){if(x=="ready"){w.bindReadyQ.push(y);}else{w.readyQ.push(x);}};var a={ready:p,bind:p};w.$=function(f){if(f===d||f===u){return a}else{p(f)}}})(window,document)</script>
    <?php if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != '') { ?>
    <script type="text/javascript" src="catalog/view/javascript/jquery/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="catalog/view/javascript/jquery/ui/jquery-ui-1.8.16.custom.min.js"></script>
    <?php } else { ?>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
    <?php } ?>
    <link type="text/css" href="catalog/view/javascript/jquery/ui/themes/ui-lightness/jquery-ui-1.8.16.custom.css" />
<?php if (defined('VERSION') && (version_compare(VERSION, '1.5.5', '<') == true)) { ?>
    <script type="text/javascript" src="catalog/view/javascript/jquery/ui/external/jquery.cookie.js"></script>
    <script type="text/javascript" src="catalog/view/javascript/jquery/colorbox/jquery.colorbox.js"></script>
    <link type="text/css" href="catalog/view/javascript/jquery/colorbox/colorbox.css" media="screen" />
    <script type="text/javascript" src="catalog/view/javascript/jquery/tabs.js"></script>
<?php } ?>
    <script type="text/javascript" src="catalog/view/javascript/common.js"></script>
    <?php foreach ($scripts as $script) { ?>
    <script type="text/javascript" src="<?php echo $script; ?>"></script>
    <?php } ?>
    <?php echo $google_analytics; ?>
  </head>
  <body>
    <div id="container">
      <div id="header">
        <?php if ($this->config->get('config_mobile_logo') && file_exists(DIR_IMAGE . $this->config->get('config_mobile_logo'))) {
            $mobile_logo = 'image/' . $this->config->get('config_mobile_logo');
        } else {
            $mobile_logo = $logo;
        } ?>
        <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $mobile_logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
        <ul>   
        <?php if (defined('VERSION') && (version_compare(VERSION, '1.5.2', '<') == true)) { ?>
                  <li><a href="<?php echo $cart; ?>" tabindex="2" id="cart" ><?php echo $text_cart; ?> (<?php echo $text_items_count; ?>)&#x200E; </a></li>

        <?php } else { ?>
                  <li><a href="<?php echo $shopping_cart; ?>" tabindex="2" id="cart" ><?php echo $text_shopping_cart; ?> (<?php echo $text_items_count; ?>)&#x200E; </a></li>
        <?php } ?>
        <?php if ( is_null($this->config->get('config_wishlist_disabled')) or (bool)$this->config->get('config_wishlist_disabled') == false) { ?>
            <li><a href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a></li>
        <?php } ?>
            <li><a href="#search" tabindex="3" id="search_link"><?php echo $text_search_link; ?></a></li>
        </ul>
      </div>
      <div id="main">
        <div id="notification"></div>

And the s.php looks like this:

<?php
require "scss.inc.php";

$scss = new scssc();
$scss->setFormatter("scss_formatter_compressed");
$scss->setImportPaths("stylesheet/");
$scss->addImportPath("stylesheet/lib");

$server = new scss_server("stylesheet", null, $scss);
$server->serve();

I noticed on the console a message that says the CSS was not opened by MIME type, text/html, it is not text/css.

I tried to change the s.php permissions to 755, 775, 777 to see if there was a problem with them and nothing. It keeps returning error 404. When I access mobile2.scss directly through the url it opens normally, that is, the file is right there. How can I fix it? I haven't dealt with SASS before so I'm completely lost.

Answer:

Man, you don't load the .scss file in your view, but what it generates, ie a css file. Make sure your file is generating a css file, and thus, import that file into the view

Scroll to Top