Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter and layouts?
#1

[eluser]NachoF[/eluser]
What CodeIgniter library can provide this funcionality??

http://media.railscasts.com/videos/008_content_for.mov

It seems so simple on rails but I just cant find a simple way to achieve this on codeigniter.. please help.. I hate having to insert my styles or javascript in the body of the document or having to go through stuff in my controllers... inserting view-specific javascript/css should be done on the view
#2

[eluser]CroNiX[/eluser]
Search CI for "asset manager" or similar. There are several libraries around. I like this one http://ellislab.com/forums/viewthread/101236/
Its pretty cool. There is a config file where you can set up defaults (like every page gets master.css and jquery library, etc). Then in the controllers you can add more specific css/js, and in your view file in the head you just $this->external->run(); and it will generate all of the needed links for css/js.

I think another I have seen around is called caribiner or something, but haven't used it.
#3

[eluser]NachoF[/eluser]
But thats not what I want.... if you watched the video you noticed he added javascript in the view file and then it got automatically added inside the head element... I dont want to have to be creating new javascript files for every view that is gonna have some custom behavior.. I just want my views to look something like this


//a way to define where this should be written
Quote:[removed]
//some javascript here
///////
[removed]
<form>
//some form here
</form>
[removed]

I have experience in both Ruby on Rails and asp.net-MVC and they both allow this... this is so frustrating[code]
#4

[eluser]CroNiX[/eluser]
OK, personally I would rather take the 2 extra minutes of time it takes (just once) to put the js in its own file and load it using an asset manager rather than wasting cpu/memory having the application parse text and rearranging things on *every* page load.

I used to do things like you are wanting to do here, until I got involved in some very high traffic sites and the waste becomes horribly apparent and slows things waaaay down.
#5

[eluser]pickupman[/eluser]
Check out the library carabiner. I like how easily I can add js in views or in controllers if I have to.




Theme © iAndrew 2016 - Forum software by © MyBB