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
Related
I have three routes in web.php
Route::get('/secondary', 'SecondaryController#show');
Route::get('/primary', 'PrimaryController#show');
Route::get('/nursery', 'NurseryController#show');
But when i click on the respective menu link, it presents the first route, others just wont work.
pls what am i doing wrongly, i need help.
this is code for the controllers
for the nursery controller
public function show($slugs){
$NurseryPages = NurseryPages::findByURL($slugs);
return view('nursery.show', ['NurseryPages' =>$NurseryPages]);
}
for the primary controller
public function show($slugs){
$PrimaryPages = PrimaryPages::findByURL($slugs);
return view('primary.show', ['PrimaryPages' =>$PrimaryPages]);
}
for the secondary controller
public function show($slugs)
{
$SecondaryPages = SecondaryPages::findByURL($slugs);
return view('secondary.show', ['SecondaryPages' =>$SecondaryPages]);
}
it will only work well for the nursery section, but on others it displays error: trying to get object of non-property and refers me back to the nursery.show file
this is the error msg
ErrorException (E_ERROR)
Trying to get property of non-object (View: C:\xampp\htdocs\acadapp\resources\views\secondary\show.blade.php)
<?php echo $__env->make('inc.secondary.navbar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<div class="container">
<div class="row">
<div class="col-md-12">
<br/><br/><br/>
<b><h3><?php echo $SecondaryPage->title; ?></b></h3>
<?php echo $SecondaryPage->body; ?>
</div>
</div>
</div>
<?php echo $__env->make('inc.secondary.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
I think you need to change your route like:
Route::get('/secondary/{slug}', 'SecondaryController#show');
Route::get('/primary/{slug}', 'PrimaryController#show');
Route::get('/nursery/{slug}', 'NurseryController#show');
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 am using codeigniter framework in my web development and passing the value of image id using php code such below
<a href="<?php echo base_url('account/gallery/view'); ?>?id=<?php echo $imageDetail['imageId']; ?>">
<img src="" />
</a>
and getting the value at controller with this code $imageId = $this->input->get('id');
With the get method I used, it will display the url like this :
http://my-domain-name/account/gallery/view?id=1
But I want to display the url like this :
http://my-domain-name/account/gallery/1
So what I did is setting in the router with this code but it's not working.
$route['account/gallery/(:num)'] = 'default/Gallery_controller/view/$1';
My web still able to show the template of the web if I type http://my-domain-name/account/gallery/1 but display error in the field that I fetch from database because unable to get the imageId
use Regex instead of :num in route.php
$route['account/gallery/([0-9]+)'] = 'default/Gallery_controller/view/$1';
And in your template file:
<a href="<?php echo base_url('account/gallery/'.$imageDetail['imageId']); ?>">
<img src="" />
</a>
Then you can access directly in your gallary controller in view function $id.
eg:
class Gallery extends MY_Controller {
public function view($id){
// Your Image ID = $id;
}
}
Set this url http://my-domain-name/account/gallery/1 proper in href
<a href="<?php echo site_url('account/gallery/view'.$imageDetail['imageId']); ?>">
<img src="" />
</a>
Replace
<a href="<?php echo base_url('account/gallery/view'); ?>?id=<?php echo $imageDetail['imageId']; ?>">
with
<a href="<?php echo base_url();?>account/gallery/view/<?php echo $imageDetail['imageId']; ?>">
Check your config.php
$config['enable_query_strings'] = true;
to
$config['enable_query_strings'] = false;
In this try this (:any)
$route['account/gallery/(:any)'] = 'default/gallery_controller/view/$1';
Or
$route['account/gallery/view?(:any)'] = 'default/gallery_controller/view/$1';
In the routes lower case
This code is make your url like http://domain-name/account/gallery/1
Try this:
<a href="<?php echo base_url();?>account/gallery/view/<?php echo $imageDetail['imageId'];?>">
<img src="" />
</a>
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>
I'll try to describe this as best as possible, i haven't encountered this problem before but maybe i'm doing something wrong.
In my controller: i have:
public function indexAction() {
$this->view->projects = $this->projects->getProjects();
}
In the view file corresponding to this controller i have:
<?php echo $this->partial('partials/sidebar/_home.phtml', array($this->projects)); ?>
My _home.phtml contains the current code:
<div class="sidebar-content">
<p class="sidebar-title">Projects Portfolio</p>
<div id='coin-slider' style="margin:0 auto;">
<?php echo $this->partialLoop('partials/sidebar/_projects-slideshow.phtml', $this->projects);?>
</div>
</div>
And my _projects-slideshow.phtml has this code:
<a href="<?php echo $this->baseUrl($this->pimage); ?>">
<img src="<?php echo $this->baseUrl($this->pimage); ?>" alt="1" />
<span>
<?php echo $this->pname . ' by ' . $this->group . '. Client: ' . $this->client; ?>
</span>
</a>
The problem is that the variable is not passed to _home.phtml. I tried a Zend_Debug::dump($this->projects) and the result was NULL. I tried a Zend_Debug::dump($this) and I found the projects array. What am I doing wrong? The variable is not being passed, or maybe it is, to _home.phtml, not to mention that _projects-slideshow.phtml has no idea what $this->projects is.
If $this->projects in your _home.phtml is empty I think you should change
in index.phtml
<?php echo $this->partial('partials/sidebar/_home.phtml', array($this->projects)); ?>
into
<?php echo $this->partial('partials/sidebar/_home.phtml', array('projects' => $this->projects)); ?>
Here how it should has been:
$variables = array (
'records' => $result
);
$this->view->partial ("nodes/relations.php", $variables);
The variables in the array are named. What exactly is in your $this->projects->getProjects() ?