• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic CSS/JS Files Not Working

#1
[eluser]Bluemill Media[/eluser]
Hi Everybody,

I'm working on a dropship ecommerce platform, and have a section of the site where I need to enable members to create templates for their stores.

I'm using Smarty to parse template data. Also, because of the way my software is setup, I'm using controllers and views to dynamically generate CSS, JS, Images, etc. However, firebug reports all of my external files as 404s, and none of my styles or scripts are applied/executed, but I can access my CSS and JS files directly with no problem.

Here is my htaccess:

Code:
RewriteEngine on
RewriteRule ^([a-zA-Z0-9\.-]+)/?$ index.php?c=home&slug;=$1 [QSA,L]
RewriteRule ^([a-zA-Z0-9\.-]+)/([a-zA-Z0-9\.-]+)/?$ index.php?c=home&slug;=$1&m;=$2 [QSA,L]
RewriteRule ^([a-zA-Z0-9\.-]+)/([a-zA-Z0-9\.-]+)/([a-zA-Z0-9\.-]+)/?$ index.php?c=home&slug;=$1&m;=$2&i;=$3 [QSA,L]

My Controller:

Code:
<?php

class Home extends Controller {

    function __construct() {
        // GRAB NECCESSARY DATA
        parent::Controller();    
        global $wpdb, $UserTools, $StoreTools;
        $this->wpdb = $wpdb;
        $this->UserTools = $UserTools;
        $this->StoreTools = $StoreTools;
    }
    
    function index() {
        // PERFORM PAGE ACTIONS
        $this->load->library('encrypt');
        $StoreSlug = (isset($_GET['slug'])) ? $_GET['slug'] : NULL;
        $StoreInfo = $this->StoreTools->store_info_slug($StoreSlug);
        if($StoreInfo) {
            $OwnerInfo = $this->UserTools->user_info($StoreInfo->Owner);
            $Theme = $this->StoreTools->get_theme($StoreInfo->Theme);
            $TemplateData = array(
                'StoreInfo' => get_object_vars($StoreInfo),
                'OwnerInfo' => get_object_vars($OwnerInfo),
                'Theme' => get_object_vars($Theme)
            );
            $this->load->_ci_varmap['smarty_parser'] = 'smarty';
            $this->load->library('smarty_parser');
            $this->smarty->parse('ci:'.$Theme->Name.'/home.tpl', $TemplateData);
        } else {
            die('Error loading template data.');
        }
    }
    function styles() {
        // PERFORM PAGE ACTIONS
        $this->load->library('encrypt');
        $StoreSlug = (isset($_GET['slug'])) ? $_GET['slug'] : NULL;
        $StoreInfo = $this->StoreTools->store_info_slug($StoreSlug);
        if($StoreInfo && isset($_GET['i'])) {
            $Theme = $this->StoreTools->get_theme($StoreInfo->Theme);
            header("Content-type: text/css");
            $this->load->view($Theme->Name.'/styles/'.$_GET['i']);
        } else {
            die('Error loading template data.');
        }
    }
    function js() {
        // PERFORM PAGE ACTIONS
        $this->load->library('encrypt');
        $StoreSlug = (isset($_GET['slug'])) ? $_GET['slug'] : NULL;
        $StoreInfo = $this->StoreTools->store_info_slug($StoreSlug);
        if($StoreInfo && isset($_GET['i'])) {
            $Theme = $this->StoreTools->get_theme($StoreInfo->Theme);
            header("Content-type: text/javascript");
            $this->load->view($Theme->Name.'/js/'.$_GET['i']);
        } else {
            die('Error loading template data.');
        }
    }

}

?>

home.tpl (Main view file)

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;title&gt;{$StoreInfo.Name}&lt;/title&gt;
    &lt;link href="/shop/{$StoreInfo.Slug}/styles/main.css" rel="stylesheet" type="text/css" /&gt;
    [removed][removed]
&lt;/head&gt;
&lt;body&gt;
<p><strong>Description:</strong> {$StoreInfo.Description}</p>
<p><strong>Owner:</strong> {$OwnerInfo.FirstName} {$OwnerInfo.LastName}</p>
<p><strong>Theme:</strong> {$Theme.Name}</p>
&lt;/body&gt;
&lt;/html&gt;

main.css

Code:
body {
    background-color: #000;
    color: #888;
}

Firebug Header Info:

Code:
Response Headers

Date                Sat, 26 Jul 2008 18:49:51 GMT
Server              Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5
X-Powered-By        PHP/5.2.5
Expires             Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control       no-cache, must-revalidate, max-age=0
Pragma              no-cache
X-Pingback          http://dev.petecommerce.com/xmlrpc.php
Last-Modified       Sat, 26 Jul 2008 18:49:51 GMT
Content-Encoding    gzip
Vary                Accept-Encoding
Content-Length      69
Keep-Alive          timeout=5, max=98
Connection          Keep-Alive
Content-Type        text/css

Request Headers

Host                dev.petecommerce.com
User-Agent          Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Accept              text/css,*/*;q=0.1
Accept-Language     en-us,en;q=0.5
Accept-Encoding     gzip,deflate
Accept-Charset      ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive          300
Connection          keep-alive
Cookie              (!HIDDEN!)
If-Modified-Since   Sat, 26 Jul 2008 07:13:48 GMT
Cache-Control       max-age=0

Response

body {
    background-color: #000;
    color: #888;
}

Any help is greatly appreciated. Smile

(Please let me know if you need more information, and what exactly you need.)


Messages In This Thread
Dynamic CSS/JS Files Not Working - by El Forum - 07-25-2008, 10:42 PM
Dynamic CSS/JS Files Not Working - by El Forum - 07-28-2008, 07:39 PM
Dynamic CSS/JS Files Not Working - by El Forum - 07-28-2008, 08:55 PM
Dynamic CSS/JS Files Not Working - by El Forum - 07-28-2008, 09:06 PM
Dynamic CSS/JS Files Not Working - by El Forum - 07-28-2008, 09:37 PM
Dynamic CSS/JS Files Not Working - by El Forum - 07-28-2008, 09:45 PM
Dynamic CSS/JS Files Not Working - by El Forum - 07-29-2008, 12:01 AM
Dynamic CSS/JS Files Not Working - by El Forum - 07-30-2008, 05:58 PM
Dynamic CSS/JS Files Not Working - by El Forum - 07-30-2008, 06:55 PM
Dynamic CSS/JS Files Not Working - by El Forum - 07-30-2008, 09:12 PM
Dynamic CSS/JS Files Not Working - by El Forum - 07-30-2008, 10:14 PM
Dynamic CSS/JS Files Not Working - by El Forum - 07-30-2008, 10:20 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.