Welcome Guest, Not a member yet? Register   Sign In
Folder place for js,css, img and plugins
#1

Hi,

i'm new on codeigniter4 and i'm not sure how the folder-structure should be.

Where is the right place for
css,js,img etc. for the layout-template
For that i think about public/assets/...

What is the right place for third-party Plugins e.g. Bootstrap, Select2 etc.
For that i think about the same but maybe subfolder.

Is it ok or it there a "must be" place or better place for this parts?
Reply
#2

(This post was last modified: 12-07-2024, 08:46 AM by captain-sensible. Edit Reason: more )

using  labels such as "assett" just complicates things, if your the coder ,then you know whats what and where you put things

this is my public :

Code:
[andrew@darkstar CI4-CMS]$ tree -L 1 public
public
├── blogImages
├── captcha
├── css
├── favicon.ico
├── fonts
├── galleryImages
├── htaccess
├── images
├── index.php
├── js
├── robots.txt
└── sounds

in js I have:


Code:
[andrew@darkstar CI4-CMS]$ tree -L 1 public/js
public/js
├── bootstrap.bundle.js
├── jquery-3.5.1.min.js
├── jquery-migrate-3.3.0.js
├── jquery-migrate.js
└── popper.js

in css :
Code:
[andrew@darkstar CI4-CMS]$ tree -L 1 public/css
public/css
├── bootstrap.css
├── custom-bk.css
├── custom-bk.css.map
├── custom.css
├── custom.css.map
├── font-face-bk.css
├── font-face.css
└── myStyle.css


myStyle.css is:

Code:
@import url("bootstrap.css");
@import url("custom.css");
@import url("font-face.css");

so basically i have a single style sheet referenced in my view; via import I pull in other style sheets. The order of pulling in means that anything in custom that has same name in bootstrap means , whats in bootstrap gets overwritten

my sqlite database goes in writable

I make use of bootstrap js for front end via in view  just before body end tag  like:


Code:
<script src="<?php echo base_url('js/popper.js');?>"></script>
<script src="<?php echo base_url('js/bootstrap.bundle.js');?>"></script>
<script src="<?php echo base_url('js/jquery-3.5.1.min.js');?>"></script>
<script src="<?php echo base_url('js/jquery-migrate-3.3.0.js');?>"></script>

in head tag of view :

Code:
<link rel="stylesheet" type="text/css" href ="<?php echo base_url("css/myStyle.css"); ?>">
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply
#3

I like to keep all my assets in one place.

.ROOT
app
system
public
-- index.php
-- assets
---- css
---- js
---- img
---- images
---- etc
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB