How to get html, js and css color markup in .php file?

I'm working on a WordPress website and as I have to give all the files a .php extension I'm loosing all my color markup I'd normally have with the javascript, html and css. So it's mostly all the same color and harder to work with.

Anyone know how I can fix that?

Thanks!

3 comments
Comment actions Permalink

Hi there,

"Settings | Template Data Languages" -- assign appropriate outer language instead of default HTML for such .php files (if you have your stuff well organized, you can apply such setting to the folder and it will propagate to all children).

0
Comment actions Permalink

I can only chose one language there. What should I do to have markup for all 4 languages in the php file?

I'm probably doing it wrong after you gave the right answer so please explain it to like I'm a child :)

Thanks for your quick first reply!

0
Comment actions Permalink

Possibly I have understood you wrong (misunderstood what kind of problem you are having).

The solution I gave you is for situation when you generate your CSS/JS (whole file) using PHP, e.g.

file.js.php (served to a browser as proper javascript file)

$(document).ready(function(){
    // -- scroll to top
    $("a[href='#<?= $myDynamicSelector; ?>']").click(function () {
        $("html, body").animate({ scrollTop: 0 }, "slow");
        $(this).blur();
        return false;
    });

   // more js code here

});


You want few languages -- it should be working just fine from scratch, e.g.

<?php
$myDynamicSelector = 'abc';
// HTML will be below
?>
<!DOCTYPE html>
<html>
<head>
    <title>Bla-bla</title>
    <style type="text/css">
        /* CSS will be available here */
        body { background-color: #222; color: #eee; }
    </style>
</head>
<body id="<?= $myDynamicSelector; ?>">
<p>Some text</p>
<p><?= 'Meow'; ?></p>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
// JS will be available here
$(document).ready(function(){
    // -- scroll to top
    $("a[href='#<?= $myDynamicSelector; ?>']").click(function () {
        $("html, body").animate({ scrollTop: 0 }, "slow");
        $(this).blur();
        return false;
    });
    // more js code here
});
</script>
</body>
</html>


Therefore: please provide an example of such file(s) stating where and what language you want to have.

0

Please sign in to leave a comment.