Welcome Guest, Not a member yet? Register   Sign In
Accessing an Assets folder in Public
#1

I tried to acces a assets folder in the public folder to stor emy js and css files is there a best praxis how to do that ? 
or do i need to change soemthign ?
Reply
#2

(02-19-2020, 08:37 AM)ByteHive Wrote: I tried to acces a assets folder in the public folder to stor emy js and css files is there a best praxis how to do that ? 
or do i need to change soemthign ?
i'm still playing around with CI 4 (on dev basis)  ; but the ways i've set up my public directory is to have in the public directory the following directories :

css
fonts
images
js

The above is pretty explanatory. in fonts dir , i have individual dirs for fontface and also font awesome.
my header view at /app/Views/
accesses a style sheet called style.css as follows:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link  rel="stylesheet" type="text/css" href="<?php echo base_url('css/style.css'); ?>   " />

i'm sure there are better ways of doing it. I've managed to get bootstrap 4 working by having these lines in style.css

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



bootstrap.css, custom.css and font-face are all in same directory   as style.css
Reply
#3

(02-19-2020, 02:13 PM)captain-sensible Wrote:
(02-19-2020, 08:37 AM)ByteHive Wrote: I tried to acces a assets folder in the public folder to stor emy js and css files is there a best praxis how to do that ? 
or do i need to change soemthign ?
i'm still playing around with CI 4 (on dev basis)  ; but the ways i've set up my public directory is to have in the public directory the following directories :

css
fonts
images
js

The above is pretty explanatory. in fonts dir , i have individual dirs for fontface and also font awesome.
my header view at /app/Views/
accesses a style sheet called style.css as follows:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link  rel="stylesheet" type="text/css" href="<?php echo base_url('css/style.css'); ?>   " />

i'm sure there are better ways of doing it. I've managed to get bootstrap 4 working by having these lines in style.css

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



bootstrap.css, custom.css and font-face are all in same directory   as style.css




Did you change the httacces file? 
Reply
#4

(This post was last modified: 02-19-2020, 02:57 PM by captain-sensible.)

(02-19-2020, 02:32 PM)ByteHive Wrote:
(02-19-2020, 02:13 PM)captain-sensible Wrote: Did you change the httacces file? 


i'm playing with CI4 in two ways ; one   is on my desktop  , so i just cd /home/andrew/Desktop/CI
php spark serve.(i running slackware

with that simple approach everything works including removing index.php from url . So no i didn't touch .htacess


Now i also have CI alomg with some other php framework running on apache on my laptop because i wanted to know how things would work on shared hosting. in other words at /var/www/htdocs i have a CI directory (codeigniter) and in htdocs dirs which have other frameworks. in this case using style sheet etc still worked, but i could not get rid of index.php .

The setup is via virtual hosts, so i edited  httpd.conf and httpd-vhosts.conf

no look . I did get rid of index.php by putting a more elaborate .htaccess in the public folder.

but on virtual host index.php was the only issue

maybe you can elaborate on assets and your set up ? with mine as you can see, css directory is straight inside public , if yours is something like public/asset/css then your path must be quoted to use them
Reply
#5

Code:
public
.. index.php
-- css
-- images
-- img
-- js
-- plugins

<link  rel="stylesheet" type="text/css" href="<?= base_url('assets/css/style.css');?>">
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

You might also be interested in this module that helps publish and load assets:
https://github.com/tattersoftware/codeigniter4-assets
Reply
#7

(This post was last modified: 02-22-2020, 02:50 PM by captain-sensible.)

(02-22-2020, 02:10 PM)MGatner Wrote: You might also be interested in this module that helps publish and load assets:
https://github.com/tattersoftware/codeigniter4-assets

So far i have font face working, font awesome , bootstrap4 nav that collapses to burger at breakpoint. I'm not finding ti too bad to link things.
For me there is no word "asset" in any path,because there is no directory "asset" anywhere simply css,js etc

Attached Files Thumbnail(s)
       
Reply




Theme © iAndrew 2016 - Forum software by © MyBB