CodeIgniter Forums
What php variable is the path to the views folder? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: What php variable is the path to the views folder? (/showthread.php?tid=68309)

Pages: 1 2 3


What php variable is the path to the views folder? - desbest - 06-22-2017

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?


RE: What php variable is the path to the views folder? - Martin7483 - 06-22-2017

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?


RE: What php variable is the path to the views folder? - arisroyo - 06-22-2017

If you want simple template you can check Codeigniter Simplicity and Support it Smile
https://www.grocerycrud.com/codeigniter-simplicity


RE: What php variable is the path to the views folder? - desbest - 06-22-2017

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?


RE: What php variable is the path to the views folder? - Paradinight - 06-22-2017

(06-22-2017, 11:07 AM)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/helpers/html_helper.html#link_tag
or
https://www.codeigniter.com/user_guide/helpers/url_helper.html#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');?>"



RE: What php variable is the path to the views folder? - desbest - 06-23-2017

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:



RE: What php variable is the path to the views folder? - Martin7483 - 06-23-2017

(06-23-2017, 03: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.


RE: What php variable is the path to the views folder? - uddin.helal - 06-23-2017

(06-22-2017, 01: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



RE: What php variable is the path to the views folder? - desbest - 06-23-2017

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/helpers/url_helper.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


RE: What php variable is the path to the views folder? - Martin7483 - 06-23-2017

How are your

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

setup?

Are you using a htaccess file?