Framework: codeigniter
Actually am facing some issue. I created an admin panel where I can change the logo of the site and it works in the panel but if I load the logo on the website index page but if I load logo in website index page then it will returns this error.
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$general_settings
Filename: views/index.php
Line Number: 6
Backtrace:
File: C:\xampp\htdocs\hrdk\application\views\index.php
Line: 6
Function: _error_handler
File: C:\xampp\htdocs\hrdk\application\controllers\Home.php
Line: 8
Function: view
File: C:\xampp\htdocs\hrdk\index.php
Line: 315
Function: require_once
http://localhost/hrdk/" alt="Logo" >
Website index page code is here
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<img src="<?= base_url($this->general_settings['logo']); ?>" alt="Logo" >
</body>
</html>
website index page controler code is here
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Home extends CI_Controller {
public function index()
{
$this->load->view('index');
}
}
Related
I am new in codeigniter.i'm trying to linked another view, but codeigniter not showing my view.here is my view code.
<div class="logo">
<img src="<?= base_url('assets/') ?>img/kliniku.png" alt="" />
</div>
<ul class="navigasi">
<li>about</li>
<li>login</li>
</ul>
</nav>
here is my controller code 'auth.php'
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Auth extends CI_Controller
{
public function index()
{
$this->load->view('auth/login');
}
}
thank you for helping me.
if you are using Xampp check your project folder
in your htaccess file you have to set RewriteBase to your folder name
RewriteBase /YOUR_PROJECT/
check your config file in application/config/config.php
$config['base_url'] = "";
check route file in application/config/route.php
$route['default_controller'] = 'YOUR_Control_NAME';
change the link as below
login
or
login
i have include a file sidebar.php in view of index page but it gives me a error like these
A PHP Error was encountered
Severity: Warning
Message: include(sidebar.php): failed to open stream: No such file or
directory
Filename: core/Loader.php(829) : eval()'d code
Line Number: 38
and other error is these
A PHP Error was encountered
Severity: Warning
Message: include(): Failed opening 'sidebar.php' for inclusion
(include_path='.;C:\xampp\php\PEAR')
Filename: core/Loader.php(829) : eval()'d code
Line Number: 38
the file sidebar.php is in the same directory and the code is as follows:
<div class="col-md-3 left_col">
<div class="left_col scroll-view">
<!-- sidebar menu -->
<?php include 'sidebar.php'; ?>
<!-- /sidebar menu -->
</div>
</div>
i am novice here so please forgive!
Use this instead of using raw php function (assuming your sidebar.php is in same directory where you will use this)
$this->load->view('sidebar');
They way you including file sidebar.php should be root folder where main index.php located.
Or you should use full file path C:\xampp\htdocs\.....YOUR PROJECT FILE DIRECToRY\sidebar.php
Or You can Use FCPATH APPPATH to get the filepath
Example
if your sidebar.php is in root folder <?php include FCPATH.'sidebar.php'; ?>
if it is inside application folder use <?php include APPPATH.'sidebar.php'; ?>
Load your sidebar in your controller
public function sources()
{
$this->load->view("pages/header/head", $data);
$this->load->view("pages/sidebar"
$this->load->view("admin/main");
$this->load->view("pages/footer/footer");
}
Of course adapted to your code
I really hope that someone can help me, because I have tried everything now in 4 days, and I am just stuck. I had a question with this before that did not get solved.
When I click one of my buttons "register" I get the following error:
Warning: include(resources/includes/header.html): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/website/php/global/registernumbers.php on line 5
Warning: include(): Failed opening 'resources/includes/header.html' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.6.2/lib/php') in /Applications/MAMP/htdocs/website/php/global/registernumbers.php on line 5
Here is the relevant code:
header.html:
<!-- 1 button in the header -->
<li>
Register 1 <!-- Error -->
</li>
<!-- registernumbers.php is called fine. I can see my <h1> and <h2> text -->
registernumbers.php:
<?php
if( !isset( $_SESSION ) ) session_start();
?>
<?php include 'resources/includes/header.html'; ?>
<h1>Register Numbers</h1>
<h2>global/registernumbers</h2>
My folder structure is looking like this:
../../php/resources/includes/header.html
Is working, but the CSS is ofcourse not called.
resources/includes/header.html
This is the correct path, but here I get the error
<?php include(ROOT_PATH . 'resources/includes/header.html'); ?>
Does not work either
The path to the header is correct, and I even tried to uinstall MAMP.
When I use this:
When I put the header.html and registernumbers.php, where my index.php is, everything is working fine.
Does anybody have a clue on what I can do? I would really like to seperate my files in folders like this.
Updated code after response
<?php
if( !isset( $_SESSION ) ) session_start();
?>
<?php define 'APP_ROOT', '/resources/includes/header.html'; ?>
<h1>Register Numbers</h1>
<h2>global/registernumbers</h2>
<?php define ('APP_ROOT', '/resources/includes/header.html'); ?>
// Here I do not get any errors, but the header is not called either
<?php define 'APP_ROOT', '/resources/includes/header.html'; ?>
//Parse error: syntax error, unexpected ''APP_ROOT'' (T_CONSTANT_ENCAPSED_STRING) in /Applications/MAMP/htdocs/website/php/global/registernumbers.php on line 5
We just launched a redesign of a client's ecommerce site running on OpenCart. We're trying to track down an error we're seeing in the Error Logs, but it's been eluding us thus far:
PHP Notice: Undefined index: route in .../vqmod/vqcache/vq2-catalog_view_theme_margaretha_template_common_header.tpl on line 360
The code on that line is:
<?php if ($this->request->get['route'] != 'common/home') { ?>
<div id="free-shipping">
<p>Free shipping on all orders!</p>
</div>
<?php } ?>
I'm not sure why this is throwing an error. Any ideas?
Change your if condition as follows:
<?php if (isset($this->request->get['route']) && $this->request->get['route'] != 'common/home') { ?>
<div id="free-shipping">
<p>Free shipping on all orders!</p>
</div>
<?php } ?>
The code may be in your theme folder's common/header.tpl or in some vqmod xml file (editing the file /vqmod/vqcache/vq2-catalog_view_theme_margaretha_template_common_header.tpl won't make any change).
Have a nice day !!
i got alot of these messages
Notice: Undefined variable: config_facontact_address in /home/oclasico/public_html/catalog/view/theme/shoppa/template/common/footer.tpl on line 50
i already seen this answer
Undefined variable (opencart)
, and i tried to do it , but i didn`t find the code to replace :(
and here is my footer.tpl line 50 look like
<?php if ($config_facontact_address) { ?>
<div class="address"><?php echo $config_facontact_address; ?></div>
<?php } ?>
my OpenCart Version 1.5.4
thanks
variable $config_facontact_address is not set,
to avoid this error use if(isset($config_facontact_address))
The reason why it's undefined is because it hasn't been set in the controller file first.
Opencart uses the MVC architecture, varibles are defined in the Controller, then used within the Template / View files. For this reason, it will always evaluate false using isset()
The code missing from the controller file (located: catalog/controller/common/footer.php) would be:
$this->data['config_facontact_address'] = $this->config->get('config_facontact_address');
If your not comfortable editing the controller, then you can replace your problem code with this:
<?php if ($this->config->get('config_facontact_address')) { ?>
<div class="address"><?php echo $this->config->get('config_facontact_address'); ?></div>
<?php } ?>