• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What php variable is the path to the views folder?

#1
I want to insert a css stylesheet and I need the php variable for the codeigniter script/app path or the views/ path to be able to do so. What is it?
Reply

#2
The constant VIEWPATH is set in the index.php.

You can use that to require of include files located in the views directory.

But what do you mean by insert a stylesheet? Do you want to inline the CSS from a stylesheet file?
Reply

#3
If you want simple template you can check Codeigniter Simplicity and Support it Smile
https://www.grocerycrud.com/codeigniter-simplicity
There are those who tell lies with meaning behind them and those meaning less lies!
Reply

#4
I have tried to insert
Code:
<link rel="stylesheet" href="<?php echo VIEWPATH; ?>stylesheet.css" type="text/css">
in my view file and it doesn't work.

It echoes
Code:
<link rel="stylesheet" href="C:\xampp\htdocs\ticketclaw\application\views\stylesheet.css" type="text/css">
And google chrome doesn't allow website to access files on the computer's hard drive, even in localhost.

Can anyone help?
Reply

#5
(06-22-2017, 12:07 PM)desbest Wrote: I have tried to insert
Code:
<link rel="stylesheet" href="<?php echo VIEWPATH; ?>stylesheet.css" type="text/css">
in my view file and it doesn't work.

It echoes
Code:
<link rel="stylesheet" href="C:\xampp\htdocs\ticketclaw\application\views\stylesheet.css" type="text/css">
And google chrome doesn't allow website to access files on the computer's hard drive, even in localhost.

Can anyone help?

First set the base url in config.php

https://www.codeigniter.com/user_guide/h...l#link_tag
or
https://www.codeigniter.com/user_guide/h...l#base_url

remove the css from the view folder.

C:\xampp\htdocs\ticketclaw/assets/css/youcssfile

PHP Code:
<link rel="stylesheet" href="<?=base_url('assets/css/youcssfile');?>"
Reply

#6
I set my base URL but I get this error when I enter this code.


Code:
<link rel="stylesheet" href="<?=base_url('');?>stylesheet.css" type="text/css">
<link rel="stylesheet" href="<?=base_url('stylesheet');?>" type="text/css">


Quote:A PHP Error was encountered
Severity: Error
Message: Call to undefined function base_url()
Filename: views/newticket.php
Line Number: 6
Backtrace:
Reply

#7
(06-23-2017, 04:03 AM)desbest Wrote: I set my base URL but I get this error when I enter this code.


Code:
<link rel="stylesheet" href="<?=base_url('');?>stylesheet.css" type="text/css">
<link rel="stylesheet" href="<?=base_url('stylesheet');?>" type="text/css">


Quote:A PHP Error was encountered
Severity: Error
Message: Call to undefined function base_url()
Filename: views/newticket.php
Line Number: 6
Backtrace:

It is clear that you have not read the provided documentation. Maybe you should start to do that.
Reply

#8
(06-22-2017, 02:09 AM)desbest Wrote: I want to insert a css stylesheet and I need the php variable for the codeigniter script/app path or the views/ path to be able to do so. What is it?

Create a folder name css or others in project directory root.
Then,
Code:
<link rel="stylesheet" href="<?=base_url('css/style.css');?>" type="text/css">

It will produce# www.example.com/css/style.css
Reply

#9
I've just read the documentation and I nearly got it to work, but it's giving me the IPV6 address instead of the IPV4 address.
I used this page

https://codeigniter.com/user_guide/helpe...elper.html

It's giving me 


Code:
<link rel="stylesheet" href="http://[::1]/ticketclaw/stylesheet.css" type="text/css">


And when I open the URL for the stylesheet I get 404 File Not Found
Reply

#10
How are your

PHP Code:
$config['base_url']
$config['index_page'

setup?

Are you using a htaccess file?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.