Welcome Guest, Not a member yet? Register   Sign In
Codeigniter functions in custom css file
#1

[eluser]Haskabab[/eluser]
Hi what's up,

I'm developing a world_map library for my codeigniter based game, and I'm currently doing the render_map() function.

I basically have 1 huge map image (3500x3500) and I only want to zoom in on a particular area (where the player is walking).

I finished the function using GD, but it takes a lot of time to render that image so I was forced to switch to using CSS.

So what i want is a div with the particular area of the map as background image, which i achieved by adding the following css to my main css file:

Code:
#world-map {
    width: 500px;
    height: 500px;
    background-color: #000;
        background-image: url(../img/world/world_map.jpg);
        background-position: 250 250;
        border: 1px solid #000;
}

Now what i want is that all these values become variables! So i can dynamically render out the final css and the world map.

The solution i found was using a .php file as an css like so:

/assets/css/world_map.php
Code:
<?php header("Content-Type: text/css;"); ?>
    
#world-map {
    width: 700px;
    height: 500px;
    background-color: #000;
           background-image: url(../img/world/world_map.jpg);
           background-position: 250 250;
           border: 1px solid #000;
}

But now i want to pass my variables through my controller, but i don't know how to transfer this data to the actual world_map.php (css) file..

I can't seem to access any codeigniter functions within the world_map.php (css) file, so the session->flashdata functions can't be used..

So my question is: how do i pass my variables from my library to my external world_map.php css file?

Thanks in advance
#2

[eluser]InsiteFX[/eluser]
I maybe wrong but I think a better solution would be to use jQuery for this!

Better user interaction etc.

Also you can change the html and classes on the fly!

InsiteFX
#3

[eluser]cahva[/eluser]
I would also recommend jQuery to do this.. But for the css question, you can create a normal controller that outputs the css for you(and you could take advantage of CI flashdata, sessions, helpers, libraries etc.) so you dont need an external world_map.php css file. Ofcourse it would add a little bit overhead to your app when you use framework to print css instead of single PHP file. But go for the jQuery as it will save you lots of time and saves bandwidth/resources on your server.




Theme © iAndrew 2016 - Forum software by © MyBB