Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Quick question
  • Hi guys

    Quick question from a new user ...

    I have the following template which is working fine ...

    <!DOCTYPE HTML>

    <html>
        <head>
    <?php echo @$css; ?>
    <?php echo @$js; ?>
    <?php echo @$title; ?>
        </head>
        <body>
            <div id ="wrapper">
                <div id="header">
    <?php echo @$header; ?>
                </div>
                <div id="content">
    <?php echo @$content; ?>
                </div>
                <div id="footer">
    <?php echo @$footer; ?>
                </div>
            </div>
        </body>
    </html>

    Now, obviously I want to populate $css, $js, and $title.

    $title is not a problem, but there could be more than one of $css and $js, and I have a thing about things being properly indented in the source, how would you do it?

    Create a view for $css and $js, and loop through it with a custom class or?

    That's the question.

    Thanks
  • HarroHarro
    Accepted Answer
    Use the Asset class for js and css.
  • Hi

    Thanks for the reply, gonna take me a while to learn fuelphp.

    So I have this now, and its fine ...

    <!DOCTYPE HTML>

    <html>
        <head>
    <?php echo Asset::js(array('jquery.js', 'test.js'));?>
    <?php echo Asset::css(array('test.css'));?>
    <?php echo @$title; ?>
        </head>
        <body>
            <div id ="wrapper">
                <div id="header">
    <?php echo @$header; ?>
                </div>
                <div id="content">
    <?php echo @$content; ?>
                </div>
                <div id="footer">
    <?php echo @$footer; ?>
                </div>
            </div>
        </body>
    </html>

    But i,m getting weird numbers appended on the end like so ...

    <!DOCTYPE HTML>

    <html>
    <head>
    <script type="text/javascript" src="http://localhost/assets/js/jquery.js?1355302140"></script>
    <script type="text/javascript" src="http://localhost/assets/js/test.js?1355301790"></script>
    <link type="text/css" rel="stylesheet" href="http://localhost/assets/css/test.css?1355301952" />
    </head>
    <body>
    <div id ="wrapper">
    <div id="header">
    </div>
    <div id="content">
    </div>
    <div id="footer">
    </div>
    </div>
    </body>
    </html>

    What are they for, are they needed, how do I get rid of them?

    Thanks again.


  • Also

    If I indent then it screws up the indentation ...

    <!DOCTYPE HTML>

    <html>
        <head>
            <?php echo Asset::js(array('jquery.js', 'test.js'));?>
            <?php echo Asset::css(array('test.css'));?>
            <?php echo @$title; ?>
        </head>
        <body>
            <div id ="wrapper">
                <div id="header">
    <?php echo @$header; ?>
                </div>
                <div id="content">
    <?php echo @$content; ?>
                </div>
                <div id="footer">
    <?php echo @$footer; ?>
                </div>
            </div>
        </body>
    </html>

    Like so ...

    <!DOCTYPE HTML>

    <html>
    <head>
    <script type="text/javascript" src="http://localhost/assets/js/jquery.js?1355302140"></script>
    <script type="text/javascript" src="http://localhost/assets/js/test.js?1355301790"></script>
    <link type="text/css" rel="stylesheet" href="http://localhost/assets/css/test.css?1355301952" />
    </head>
    <body>
    <div id ="wrapper">
    <div id="header">
    </div>
    <div id="content">
    </div>
    <div id="footer">
    </div>
    </div>
    </body>
    </html>

    This is the thing that drives me nuts. Is there a workaround? I want everything inside the head tags to have an extra indent and be consistent down the document.

    Thanks again.

  • It's HTML, a browser doesn't care about indentation. Whitespace is not relevant.

    The number in the URL is a version check. It makes sure that if you update the file, the cached version in the browser will be replaced (so your users don't have to flush the browser cache to see the new version of the css or js file).
  • Ah I see, that's a good feature.

    Yeah, I am aware that the browser doesn't care about white-space, but I do, it drives me nuts.
  • Hey

    The functions also seem to add indentation on there own. Is there a way to turn this off?

    Thanks
  • Yes, there is.

    config/assets/indent_level

    Sorted.

    Thanks

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion