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>
Related
I want to put the photos in the uploads folder but when I try to call the variable from the controller to the view it generates an Undefined Variable error
File : application/controllers/ubah_profile.php
public function ubah_profile()
{
$data['foto'] = $this->db->get_where('user',array('id'=>$this->session->userdata('id')),1)->row()->foto;
$this->load->view('top',$data);
$this->load->view('upload_foto');
$this->load->view('bottom');
}
File : application/views/top.php
<ul class="nav navbar-nav">
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="<?php echo base_url() ?>uploads/<?php echo $foto; ?>" class="user-image" alt="User Image">
<span class="hidden-xs">Admin</span>
</a>
</li>
</ul>
You should change the form type my friend.
That’s why the controller can’t recieve the file info.
Btw, judulnya ada campuran bhs indo wkwk.
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 have this html code
<body>
<div class="wrapper">
<div class="banner">
</div>
<div class="nav_bar">
<ul>
<li>Home</li>
<li>News</li>
<li>Registration FAQs</li>
<li>How to Register and Rules</li>
<li>Register school</li>
<li>Register pupil</li>
<li>About Us</li>
<li>Contact Us</li>
</ul>
</div>
<div class="content_area">
**<?php echo $content; ?>**
</div>
<div class="clear"></div>
</div>
<div class="footer">
<div>
</div>
</div>
</body>
now once the user clicks the links i want to load the content depending on which link he has clicked as you can see inn the code above. I can load the content as long as its all html but now that php tags are included i find it hard. how do i load the content with the following data?
<div id="form_input">
<?php
echo form_open('form/data_submitted');
// Show Name Field in View Page
echo form_label('User Name :', 'u_name');
$data= array(
'name' => 'u_name',
'placeholder' => 'Please Enter User Name',
'class' => 'input_box'
);
echo form_input($data);
// Show Email Field in View Page
echo form_label('User email:', 'u_email');
$data= array(
'type' => 'email',
'name' => 'u_email',
'placeholder' => 'Please Enter Email Address',
'class' => 'input_box'
);
echo form_input($data);
?>
</div>
// Close Form
<?php echo form_close();?>
is it possible?
I would suggest the following:
Your Controller:
class Site extends CI_Controller
{
public function home()
{
$arrViewData = array
(
"content" = $this->load->view("site/home","",true)
);
$this->load->view("index", $arrViewData);
}
}
your view called i.e. index
<html>
<body>
<div class="wrapper">
<div class="banner">
</div>
<div class="nav_bar">
<ul>
<li>Home</li>
<li>News</li>
<li>Registration FAQs</li>
<li>How to Register and Rules</li>
<li>Register school</li>
<li>Register pupil</li>
<li>About Us</li>
<li>Contact Us</li>
</ul>
</div>
<div class="content_area">
<?= $content; ?>
</div>
<div class="clear"></div>
</div>
<div class="footer">
<div>
</div>
</div>
</body>
</html>
your view called home.php in views/site/
hello i'm home
with this method i think you can achieve what you want if i understand you correctly
as a side note: this is an example - but you should be able to see the point
You might want to consider breaking your view html into a smaller "snippets". CodeIgniter (CI) makes it easy to load them in the order you want and then "show" them all at once.
One possible breakdown of views into snippets follows.
header_view.php
<!DOCTYPE HTML>
<html>
<head>
<title>
<?= (isset($page_title)) ? $page_title : "Rapids Riders"; ?>
</title>
In the next view snippet I put some URLs in the links to serve as examples using the CI controller/function syntax. Adjust to your needs. To my thinking "home", "news" and "register" are separate controllers. I will focus on the Registration controller in a bit.
If you're not familiar with <?= it is shorthand for <?php echo.
body_start_view.php
<body>
<div class="wrapper">
<div class="banner">
</div>
<div class="nav_bar">
<ul>
<li><a href=<?= base_url("home"); ?>>Home</a></li>
<li><a href=<?= base_url("news"); ?>>News</a></li>
<li><a href=<?= base_url("register/faq"); ?>>Registration FAQs</a></li>
<li><a href=<?= base_url("register/help"); ?>>How to Register and Rules</a></li>
<li><a href=<?= base_url("register/school"); ?>>Register school</a></li>
<li><a href=<?= base_url("register/pupil"); ?>>Register pupil</a></li>
<li><a href=<?= base_url("home/about"); ?>>About Us</a></li>
<li><a href=<?= base_url("home/contact"); ?>>Contact Us</a></li>
</ul>
</div>
footer_view.php
<div class="clear"></div>
</div>
<div class="footer">
<div>
</div>
</div>
</body>
</html>
These three view snippets are easily reused by any controller on the website. A controller based "helper" function is shown below (in the registration controller) to demonstrate implementing a sort of "templating" scheme.
The example form html will be in a file called pupil_form_view.php and would be used (in my example) for the register/pupil page.
When using an MVC app structure you typically want to set as much "data" as possible in the controller and then pass it to the view. The various vars in this file will be defined and set in the controller calling this view.
pupil_form_view.php
<div id = "form_input">
<?php
echo form_open($form_action);
// Show Name Field in View Page
echo form_label($name_field['label'], $name_field['name']);
echo form_input($name_field);
// Show Email Field in View Page
echo form_label($email_field['label'], $email_field['name']);
echo form_input($email_field);
?>
</div>
// Close Form
<?php echo form_close(); ?>
Register.php is a controller that handles multiple pages - faq, help, school, pupil
class Register extends CI_Controller
{
function __construct()
{
parent::__construct();
}
//pupil will show the pupil registration form
public function pupil()
{
$view_file = "pupil_form_view"; //the file name of a view to load
$data['page_title'] = "Pupil Registration";
$data['form_action'] = 'form/data_submitted';
//form fields info
$data['name_field'] = array(
'label' => 'User Name: ',
'name' => 'u_name',
'placeholder' => 'Please Enter User Name',
'class' => 'input_box'
);
$data['email_field'] = array(
'type' => 'email',
'name' => 'u_email',
'placeholder' => 'Please Enter Email Address',
'class' => 'input_box'
);
//output a page
$this->render_page($view_file, $data);
}
//This function handles all the repetitive view loading code.
//Just pass it the name of a view file and some data to use in the views
//The default value for $view_data means you don't HAVE TO pass this argument if not needed
protected function render_page($content, $view_data = NULL)
{
//notice the use of 'method chaining' for load functions
$this->load
->view('header_view', $view_data)
->view('body_start_view')
->view($content) //$view_data vars will be visible to this view file
->view('footer_view');
}
public function faq()
{
$data['page_title'] = "Frequently Asked Questions";
$view_file = "faq_view";
//other data setting code if needed
$this->render_page($view_file, $data);
}
public function school()
{
$data['page_title'] = "School Registration";
$view_file = "school_form_view";
//other data setting code
$this->render_page($view_file, $data);
}
public function help()
{
$data['page_title'] = "How to Register";
$view_file = "help_view";
//other data setting code
$this->render_page($view_file, $data);
}
function index()
{
//just load the help page when users navigate to example.com/register
$this->help();
}
}
I know I went overboard here. Hope this is useful.
I solved it by nesting views that is calling $this->load->view($content); within my template view instead of <?php echo $content;?> then on the controller function i loaded the content like this
$data['content']='view_name_here'; // this loads content with a view
$this->load->view('my_template',$data); //loaded my template with $content
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
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);
}