Views:
I got the error when i run the program : undefined variable site in views
This is the following code:
<ul class="nav nav-pills">
<li>HOME</li>
<li>ABOUT US</li>
<li>SERVICES</li>
<li>PHOTO GALLERY</li>
<li>PROMO GALLERY</li>
<li>CONTACT</li>
</ul>
Moreover i got the error in views undefined variable image in the following code:
<img src="<?php echo $base?>/<?php echo $image?>/fb.png" alt="" title="" />
Also i got the error like undefined variable css, base
<link rel="stylesheet" href="<?= base_url() ?>assets/css/style.css" />
<link rel="stylesheet" href="<?= base_url() ?>assets/css/bootstrap.min.css" type="text/css" />
Please provide solution for this issue.
Its because $site is not contain any value.
this should be
<?php echo $site ?>
this
<?php echo base_url() ?>
And do this Configuration as well (This will help to use base_url function)
In config/config.php
$config['base_url'] = '';
In config/autoload.php
$autoload['helper'] = array('url')
class Timelinestudio extends CI_Controller{
var $data;
function __construct(){
parent::__construct();
//session_start();
$this->load->model('timeline_model');
$this->load->library('form_validation');
$this->data = array(
'site' => $this->config->item('site_url'),
'base' => $this->config->item('base_url'),
'css' => $this->config->item('css'),
'js' => $this->config->item('js'),
'img'=>$this->config->item('img'),
'image'=>$this->config->item('image')
);
// $data = $this->data;
//print_r($data); die();
}
public function index()
{
$this->load->helper(array('form','url'));
$data = $this->data;
//print_r($data); die();
$this->load->model('timeline_model');
$data['slideimg']=$this->timeline_model->get_slideimg();
$this->load->view('index',$data);
}
Related
I already write a code logo/img on header.php
but, when I going to refresh, a logo doesn't want to show up.
Is there a solution?
I used a bootstrap 4, simple html and css. I've tried many times but always fail.
In any features, a logo already show, but in "tambahalternatif" doesn't want to show
and here is my controller :
<?php
class Alternatif extends CI_Controller{
public function __construct()
{
parent::__construct();
$this->load->model('Alternatif_model');
$this->load->library('form_validation');
}
public function index()
{
$data ['judul'] = 'Isi Alternatif';
$data ['alternatif'] = $this->Alternatif_model->getAllAlternatif();
if($this->input->post('key')){
$data['alternatif'] = $this->Alternatif_model->cariDataAlternatif();
}
$data['hasil'] = $this->Hitung(); //Manggil fungsi Hitung()
$this->load->view('templates/header',$data);
$this->load->view('alternatif/index', $data);
$this->load->view('templates/footer' );
}
public function tambahalternatif()
{
$data['judul'] = 'Form Tambah Data Alternatif';
// $this->form_validation->set_rules('idclient','ID','required|numeric');
$this->form_validation->set_rules('namaalt','NAMA','required');
if ($this->form_validation->run() == FALSE) {
$this->load->view('templates/header', $data);
$this->load->view('alternatif/tambahalternatif');
$this->load->view('templates/footer');
} else {
$this->Alternatif_model->tambahDataAlternatif();
$this->session->set_flashdata('flash','Berhasil');
redirect('alternatif');
}
header view
<nav class="navbar navbar-expand-lg navbar-light bg-light navbar-fixed-top ml-right">
<div class="container"><a class="navbar-brand" href="<?=base_url(); ?>" ><img class="logo" src="./img/logo.png" height="28px;" padding="2px 10px;></a>
i expect a image(logo) will show in "tambahalternatif", but image(logo) only show in "alternatif" only
Try this code in the header
<body>
<img src="<?php echo base_url();?>imag/logo.png" height="28px" alt="">
</body>
Use base bath instead of absolute path.
replace
<img class="logo" src="./img/logo.png" height="28px;" padding="2px 10px;>
with below line
<img class="logo" src="<?php echo base_url(); ?>img/logo.png" height="28px;" padding="2px 10px;>
So that when you change your view's path, the logo's path will no need to change.
***Try this one & let us know is it ok now.
Thanks.***
<nav class="navbar navbar-expand-lg navbar-light bg-light navbar-
fixed-top ml-right">
<div class="container">
<a class="navbar-brand" href="<?= base_url(); ?>" >
<img class="logo" src="<?= base_url().'img/logo.png'; ?>"
height="28px" padding="2px 10px">
</a>
</div>
</nav>
I have a controller with two functions as below
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class User extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('User_model');
}
public function index() {
$this->load->view('registration/index');
}
public function login() {
$this->load->view('registration/index');
}
and following in the header.php file
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url("user/login")?>">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo site_url("user")?>">Register</a>
</li>
My problem is when I click on register button with site_url('user'), its working fine but when i click login button with site_ur('user/login') my css are not loaded. I have tried the same view for both the function. But later one is showing problem.
Can anybody help me what configuration mistake I did. My file structure of view folder is:
- views
-registration
-index.php
-index_script.php
templates
-header.php
-footer.php
-html_header.php
index.php has
<?php $this->load->view("templates/html_header");
$data = array();
$data["additional_script"] = $this->load->view("registration/index_scripts", array(), true);
$this->load->view("templates/footer", $data);
?>
html_header.php contains
<!-- include angular js -->
<script src="libs/angular/angular.min.js"></script>
<link href="libs/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="assets/css/clean-blog.min.css" rel="stylesheet">
<?php $this->load->view("templates/header")?>
header.php
The URL you are using is incorrect. You must add <?php echo base_url(); ?> to the script src.
For eg: <script src="<?php echo base_url(); ?>libs/angular/angular.min.js"></script>
Maybe this can work.
I'm creating a Server Side php Website application.
In my first page , the whole code is php , and I've set
$_SESSION["lang"] = 'lang.en.php';
$_SESSION["lang"] = 'lang.it.php';
When I change flag, I change a variable :
if (Trim($_SESSION["lang"])=='')
{
include 'lang.it.php';
}
if (Trim($_SESSION["lang"])=='lang.en.php')
{
include 'lang.en.php';
}
if (Trim($_SESSION["lang"])=='lang.it.php')
{
include 'lang.it.php';
}
I have the following problem
My second page .php is 50% html and 50% php because in html I put a simple dropdown menu.
My Question is : How can I pass to html my variables from another php page without using Jquery?
<li> <a class="active" href="home.php"><?php $home?></a> </li>
Variable $Home is stored in - lang.it.php -
How di I access to my variables?
P.s.
I don't want to pass all Menu's variable in the session because I think is crazy to do..
EDIT --
html
<head>
<link href="Css/Menu.css" rel="stylesheet" type="text/css">
<script>
</head>
<body>
<center ><div id="header"><center >
<ul>
<li><a class="active" href="home.php">Home</a></li>
<li>Area Download</li>
<li class="dropdown">
<a href="javascript:void(0)" class="dropbtn"
onclick="myFunction()">MenĂ¹</a>
<div class="dropdown-content" id="myDropdown">
VARIABLE 1 HERE
VARIABLE 2 HERE
VARIABLE 3 HERE
</div>
<li>Logout</li>
</li>
</ul>
</div>
<center ><div id="Realbody"><center >
<center ><div id="Footer"><center >
</html>
<?php
require_once("rpcl/rpcl.inc.php");
//Includes
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");
use_unit("styles.inc.php");
include 'parameters.php';
//Class definition
class PaginaDownload extends Page
{
public $Label1 = null;
public $LoginCss = null;
function PaginaDownloadShow($sender, $params)
{
if ((empty($_SESSION["name"])) || (empty($_SESSION["user"])))
{
header('Location: \index.php');
}
}
}
global $application;
global $PaginaDownload;
//Creates the form
$PaginaDownload=new PaginaDownload($application);
//Read from resource file
$PaginaDownload->loadResource(__FILE__);
//Shows the form
$PaginaDownload->show();
?>
I've to replace VARIABLE 1 , 2 , 3 with my variable on Lang.php
<li><a class="active" href="home.php">Home</a></li>
<li><a class="active" href="home.php"><?php $home?> </a></li>
That's my try :
//Includes
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");
use_unit("styles.inc.php");
use_unit("Zend/zauth.inc.php");
include '/parameters.php';
if (Trim($_SESSION["lang"])=='') { include 'lang.it.php'; }
else
include Trim($_SESSION["lang"]);
//Class definition
and here my lang file
<?php
/*
------------------
Language: English
------------------
*/
//Login Page #1/X
$title_page_Login = 'Login';
$Err_1_Login = 'Login Credentials Incorrect';
$Err_2_Login = 'Not Found User :';
$Err_3_Login = 'Database Offline';
$Err_4_Login = 'Insert User & Password';
$Err_5_Login = 'Need User';
$Err_6_Login = 'Need Password';
$req_user = 'Insert Username';
$req_pass = 'Insert Password';
$Bt_Label = 'Sign In';
//-------------------
//Home
$home = 'Home';
?>
i am modifying a custom 404 page which is already in views-> errors folder.
the problem is when i extend the master layout then it is showing an error
Call to a member function getName() on a non-object
at "Route::current()->getName()=='home'"
<nav class="pmh-navigation mdl-navigation mdl-layout--large-screen-only">
<a class="mdl-navigation__link mdl-typography--text-uppercase <?php echo (Route::current()->getName()=='home')?'active':'' ?>" href="{{URL::route('home')}}">Home</a>
<a class="mdl-navigation__link mdl-typography--text-uppercase <?php echo (Route::current()->getName()=='blog')?'active':'' ?>" href="{{URL::route('blog')}}">Blog</a>
<a class="mdl-navigation__link mdl-typography--text-uppercase <?php echo (Route::current()->getName()=='about-us')?'active':'' ?>" href="{{URL::route('about-us')}}">About</a>
<a class="mdl-navigation__link mdl-typography--text-uppercase <?php echo (Route::current()->getName()=='contact')?'active':'' ?>" href="{{ URL::route('contact') }}">Contact</a>
</nav>
what i am doing wrong? Please help me...
$request->path();
just try this
Its give me this error
Unable to resolve the request
"Customerlifecycle/Customerlifecycleanalytic".
Here is my code:
Costomerlifecycle Controller
Yii::app()->clientScript->scriptMap = array('jquery.js' => false, 'jquery-ui.min.js' => false, 'jquery-ui.css' => false);
class Customerlifecycle extends Controller {
public $layout = '//layouts/column2';
public function actionCustomerlifecycleanalytic() {
}
}
index.php
<li class="">
<a class="subpageaccess" href="<?php echo CHtml::normalizeUrl(array('Customerlifecycle/Customerlifecycleanalytic')); ?>">
Customer Life Cycle Analytics</a>
</li>
try with first character lowercase.
Because the name of the controller and of the action in url is lowercase. this is the yii convention..
<li class="">
<a class="subpageaccess" href="<?php echo
CHtml::normalizeUrl(array('customerlifecycle/customerlifecycleanalytic')); ?>">
Customer Life Cycle Analytics</a>
</li>