Welcome Guest, Not a member yet? Register   Sign In
Self Contained Modules (css, js etc.)
#1

[eluser]Sven Delle[/eluser]
I saw a post on this, but it all ended with a comment: put your assets in your root directory, and a link to a no longer maintained library from Sturgeon.

Now, are there any news to this topic?

I absolutely agree that the whole point of modules it to keep ALL code and assets in ONE place - and not scattered all over the place.

So how would one go about enabling css, javascript and other assets in the modules directory and link to them properly?
#2

[eluser]Otemu[/eluser]
Check out Sturgeon template library here:
https://github.com/philsturgeon/codeigniter-template

Also guide here:
http://philsturgeon.co.uk/demos/codeigni...brary.html

Using prepend_metadata() and append_metadata() can handle Asset management
#3

[eluser]Sven Delle[/eluser]
Yeah, saw that. I've coded my own way of prepending css and javascript files. But it doesn't solve the 'problem' of having EVERYTHING belonging to ONE module in ONE place, or did I miss a point here?
#4

[eluser]PhilTem[/eluser]
You can have the same structure within your module for your assets. Imagine the following structure

Code:
assets
  |- styles
  |- scripts
  |- images
application
  |- modules
      |- some_module
          |- assets
              |- styles
              |- scripts
              |- images
          |- config
          |- libraries
          |- views
      |- some_other_module
          |- assets
              |- styles
              |- scripts
              |- images
          |- libraries
          |- models
          |- views
system
index.php

where the assets folder at the web-root is the place to store side-wide assets.
Then just link to the module's asset with e.g.

Code:
http://www.example.com/application/modules/some_module/assets/scripts/javascript.js

Maybe you should have a look at pyrocms on how they handle these module-specific assets besides side-wide assets.

I personally have the scripts and styles for the general layout stored under ./assets/(scripts|styles) and for modules they go to the modules directory just like I wrote above. You could also make an assets-controller that controls your assets to the directory-structure won't ever be exposed to the user.
#5

[eluser]Aken[/eluser]
In recent CI versions, there is an .htaccess file inside the application directory that will prevent ALL web requests to any and all files inside the application folder. So just tossing files into the application directory will not work unless you want to remove that .htaccess file, which is not recommended.

Ideally, you'll never have them packaged into one place, because you'll want to separate your application's files just as much as you'd separate the code logic. Consider using a "theme" folder in addition to your module folder. At least that way you'll only have two directories to worry about, to minimize any issues.




Theme © iAndrew 2016 - Forum software by © MyBB