create master page layout in codeigniter master-page layout - php

I am trying to create master page layout in conditioner.But problem is that .I am getting page load error .
I have Header.php ,footer.php ,sidebar.php
Dashboar_view.php page is this
<?php include_once('common/header.php');?>
<div class="content-wrapper">
<div class="container-fluid">
<!-- Breadcrumbs-->
<ol class="breadcrumb">
<li class="breadcrumb-item">
Dashboard
</li>
<li class="breadcrumb-item active">My Dashboard</li>
</ol>
</div>
<!-- HERE WILL BE ALL PAGE DATA WILL BE SHOWN -->
<?php $this->load->view($content); ?>
</div>
<!-- /.container-fluid-->
<!-- /.content-wrapper-->
<?php require_once('common/footer.php');?>
And here is my controller function Dashboard.php
public function viewchart()
{
$data = array('content'=>'viewchart');
$this->load->view('admin/dashborad_view',$data);
}
getting error
Unable to load the requested file: viewchart.php.
nay help regarding create dynamic master layout for page content load.
Thanks

Hope this will help you :
if charts_view.php is a file in view folder you want to show in your dashboard
Your controller should be like this :
public function viewchart()
{
$chart_content = $this->load->view('charts_view',TRUE);
$data = array('chart_content'=> $chart_content);
$this->load->view('admin/dashborad_view',$data);
}
Your view should be like this :
<?php include_once('common/header.php');?>
<div class="content-wrapper">
<div class="container-fluid">
<!-- Breadcrumbs-->
<ol class="breadcrumb">
<li class="breadcrumb-item">
Dashboard
</li>
<li class="breadcrumb-item active">My Dashboard</li>
</ol>
</div>
<!-- HERE WILL BE ALL PAGE DATA WILL BE SHOWN -->
<?php echo $chart_content; ?>
</div>
<?php require_once('common/footer.php');?>
for more : https://www.codeigniter.com/user_guide/general/views.html#returning-views-as-data

Related

Bootstrap Layout when using PHP Foreach

I am currently displaying content from my database using a foreach loop within a boostrap panel. However the layout is not behaving as I expected it too, I have tried resolving this using breaks which had fixed the layout from being worse than it is at the present. However it is still off if you take a look at the image below :-
In addition to this I also have bootstrap dropdown menu's that are not working at all embedded within a div.
This is my code -
<div class="parabox">
<!-- Collect the nav links, forms, and other content for toggling -->
<!-- Search -->
<form class="navbar-form navbar-left">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search For Comics">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<strong><p class="navbar-text">Sort Comics By : </p></strong>
<ul class="nav navbar-nav">
<li class="dropdown">
Order Comics<span class="caret"></span>
<ul class="dropdown-menu">
<li>Ascending Order</li>
<li>Descending Order</li>
<li>Numerical Order</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
Universe<span class="caret"></span>
<ul class="dropdown-menu">
<li>Dark Horse Comics</li>
<li>DC</li>
<li>IDW</li>
<li>Image</li>
<li>Marvel</li>
<li>Valiant</li>
</li>
</ul>
</div>
</div>
</br>
<!-- Start of Col Div -->
<div class="col-md-12">
<!--/.Panel for Comics -->
<!-- Count for Comics -->
<?php
if(count($comics)){
?>
</br>
<div class="panel panel-default">
<div class="panel-heading panel-heading-green">
<h3 class="panel-title">My Comics</h3>
</div>
<div class="panel-body">
<div class="row">
<!--/.row1 -->
<!-- Display each comic by id -->
<?php foreach($comics as $list): ?>
</br>
<div class="col-md-3 comic">
<a href="#">
<?= ($list['image'] <> " " ? "<img style='max-width:200px; max-height:250px;' src='Images/{$list['image']}'/>" : "") ?>
</a>
<div class="comic-title">
<?= ($list['name'] <> "" ? $list['name'] : "") ?> #<?= ($list['issue'] <> "" ? $list['issue'] : "") ?>
</div>
<div class="comic-add">
</div>
</div>
<!-- End of Foreach Statement for Comics -->
<?php endforeach; ?>
<!-- Else show this message if user has no entries -->
<?php
}else {
?>
<p><b>You haven't posted any comic yet!</b></p>
<?php } ?>
</div>
</div>
</div>
<!--/.row1-collapse -->
</div>
<!-- /.container -->
</div>
I am using MVC format which is why the code may seem short or missing pieces which is in header and footers within my template part of my application. Any ideas on what I can do to sort the layout out and get the dropdown menu's to work as they do seem a little related ?
As far as I know, bootstrap requires you to always have a markup like:
<div class="container">
<div class="row">
<div class="col-*">…</div>
<!-- many more cols -->
</div>
</div>
So this:
container
row
col
col
col
row
…
structure should always be give, whereby this structure can be nested.
This way the layout has all the negative margin magic applied
UPDATE
According to the posted image I guess that the resulting markup is corrupted (if the »container > row > col« structure exists). I recommend to have a a look at the browser console and compare the resulting dom tree with the expected. It is also very helpful to search the page source, in Firefox corrupted elements (missing closing tag, wrong attributes etc) are shown in red, so this helps to find the bug.
*Create a wrapper div to hold the image, title etc. Then for that div add a css with the style as display:inline-block; So if it is not able to accomodate with in the view in browser, it will get automatically wrapped into the next line. Follow this example see teh working sample code created by some one: http://jsfiddle.net/ajruk60t/3/*
You must break your line after the number of columns your row can contain. For instance, if you use col-3, then you must not define more than 4 columns. At this point, you recreate a row and carry on.
<div class="row">
<?php
$i = 1;
foreach($comics as $list) { ?>
<div class="col-md-3">
...
</div>
<?php
if ($i % 4 == 0) {
?></div><div class="row"><?php
}
$i++;
?>
<?php } ?>
</div>
Alternatively, you can create the same effect adding manual breakpoints rather than recreating a row. I have not tried this solution myself, but read it here:
<div class="clearfix visible-md-block"></div>
Thank you for your help it steered me to the answer which was the foreach loop had to start after the break.
<?php require('template/header.phtml') ?>
<div class="container">
<div class="row">
<!-- Start of Col Div -->
<div class="col-md-12">
<!--/.Panel for Comics -->
<!-- Count for Comics -->
<?php
if(count($comics)){
?>
</br>
<div class="panel panel-default">
<div class="panel-heading panel-heading-green"><h3 class="panel-title">My Comics</h3></div><!-- End of Panel Heading -->
<div class="panel-body">
<div class="row">
<!--/.row1 -->
<!-- Display each comic by id -->
</br> <?php foreach($comics as $list): ?>
<div class="col-md-3 comic">
<a href="#">
<?= ($list['image'] <> " " ? "<img style='max-width:200px; max-height:250px;' src='Images/{$list['image']}'/>" : "") ?>
</a>
<div class="comic-title">
<?= ($list['name'] <> "" ? $list['name'] : "") ?> #<?= ($list['issue'] <> "" ? $list['issue'] : "") ?>
</div>
<div class="comic-add">
</div>
</div> <!-- End of Col-MD-3 Comic -->
<!-- End of Foreach Statement for Comics -->
<?php endforeach; ?>
<!-- Else show this message if user has no entries -->
<?php
}else {
?>
<p><b>You haven't posted any comic yet!</b></p>
<?php } ?>
</div><!-- end of row -->
</div> <!-- end of panel body -->
</div> <!-- end of panel panel-default -->
<!--/.row1-collapse -->
</div> <!-- end of col-md-12 -->
</div> <!-- End of Row -->
</div> <!-- /.container -->
<?php require('template/footer.phtml') ?>

How to spilt tabs jquery file with codeigniter?

Hi all I am a new of codeigniter I have stuck it a few day I a have problam with my jquery tab I can not split it I try to search google and youtube but I can not do it who can help me please Example My jquery Tab:
<div id="demopage">
<div class="container1">
<ul class="rtabs">
<li>menu</li>
<li>Contact</li>
<li>About</li>
</ul>
<div class="panel-container">
<div id="menu">
<p>menu</p>
</div>
<div id="contact">
<p>contact</p>
</div>
<div id="about">
<p>about</p>
</div>
</div>
and I try to edit in view and controller:
View
<div id="demopage">
<div class="container1">
<ul class="rtabs">
<li>menu</li>
<li>Contact</li>
<li>About</li>
</ul>
<div class="panel-container">
<div id="menu">
<p>menu</p>
</div>
<div id="contact">
<p>contact</p>
</div>
<div id="about">
<p>about</p>
</div>
</div>
And my controller:
function menu(){
$this->load->view('header');
$this->load->view('menu');
$this->load->view('footer');
function contact(){
$this->load->view('header');
$this->load->view('contact');
$this->load->view('footer');
function about(){
$this->load->view('header');
$this->load->view('about');
$this->load->view('footer');
}
I hope header and footer will be same for all, If so,
function your_function_name(){
$data['menu'] = $this->load->view('menu',"",true);
$data['contact'] = $this->load->view('contact',"",true);
$data['about'] = $this->load->view('about',"",true);
$this->load->view("your_view_file",$data);
}
Third parameter to view, will get the view in to a variable instead of loading it to the view. So collect all views and echo in main view file.
in view
<div class="panel-container">
<div id="menu">
<p><?php echo $menu ?></p>
</div>
<div id="contact">
<p><?php echo $contact ?></p>
</div>
<div id="about">
<p><?php echo $about ?></p>
</div>
</div>
Solution:
1) You need to include respective jQuery files.
2) Change your <li> 's href attribute to proper tab.
3) In your case, remove <?php echo base_url()?>.
4) The correct syntax should be: <li>menu</li>
Explanation:
jQuery tabs work as following:
1) First create a <ul> for tab headers.
2) For each <li>, a named anchor to content with href=#id-of-the-content.
3) By clicking on a <li>, only respective content will show, others will hide.

Page not loading after php include

I have a page which includes the menu bar (a php page). This works, but strangely the page doesn't load after the include.
Some code:
<div class="center">
<?php
include ('../menu.php')
?>
<div class="text" id="media">
Some text
</div>
When I add the
<div class="text" id="media">
Some text
</div>
to the menu.php it is showed, but not when it is on the parent page. Anybody has an idea? There isn't any warning or error showing.
<!-- begin menu -->
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<link rel="stylesheet" href="../../../../style/menu.css">
<div class="menu_b">
<div class="logo">
<img src="../../../../afbeeldingen/menu/logo.gif" width="375" title="Home" />
</div>
<div class="aangemeld">
</div>
<ul class="menu_tekst">
<li class="<?php echo $account_li;?>"><a class="nt" href="../../../../account.php">Account</a></li>
<li class="tussenstuk"></li>
<li class="<?php echo $contact_li;?>"><a class="nt href="../../../../contact.php">Contact</a></li>
<li class="tussenstuk"></li>
<li class="<?php echo $fotos_li;?>"><a class="nt" href="../../../../fotos.php">Foto's</a>
<ul class="sub_fotos sub">
<li class="space_left"> </li>
<li class="titel_blok_sub"><a class="nt" href="../../../../fotos/2013_2014.php">2013-2014</a></li>
<li class="titel_blok_sub"><a class="nt" href="../../../../fotos/kamp.php">Kampfoto's 2014</a></li>
</ul>
</li>
<li class="tussenstuk"></li>
<li class="nt"><a class="nt" href="../../../../winkelwagen.php">winkelwagen + besteld</a></li>
</ul>
</div>
<div class="onder_menu">
</div>
<div class="sub_menu">
</div>
<!-- einde menu -->
you forgot semicolon ;
include ('../menu.php');
You forgot a quotation mark:
<li class="<?php echo $contact_li;?>">
<a class="nt href="../../../../contact.php">Contact</a>
</li>
should be
<li class="<?php echo $contact_li;?>">
<a class="nt" href="../../../../contact.php">Contact</a>
</li>
Succes ermee
Above the div.center their was an other php include of a page that doesn't exist, after removing it, the page loaded. Didn't looked at it because it was above the menu.php which was loaded.
Try using require:
require('../menu.php');
I'm guessing that you have turned off display errors in your php.ini and that menu.php doesn't exist.
If you are not sure how to turn on error reporting in your development machine, add the following lines to your parent page;
<div class="center">
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include ('../menu.php');
?>
<div class="text" id="media">
Some text
</div>
This should then reveal why the page is not being included.
Take the parenthesis off the include statement. It should look like this:
include 'page.php';

laravel 4 - how to show and hide components in blade?

I have breadcrumbs in my master.blade.php file and i want the breadcrumbs to be used everywhere BUT the homepage.blade.php.
right now this is how i add links to the breadcrumbs in other pages like "About".
about.blade.php:
#section('breadcrumbs')
#parent
<li class="last-breadcrumb">
About
</li>
#stop
in the master.blade.php:
<div class="container">
<div class="breadcrumb-container">
<ul class="breadcrumb">
#section('breadcrumbs')
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
</div>
but i don't want the breadcrumbs code to display at all when homepage.blade been used.
copying the code for each about.blade/X.blade files seems like a bad idea..
Your can set a value in your controller that you pass with the make/redirect like $data['breadcrumb'] = true and wrap your breadcrumb code in an conditional. This kind of system also works well for error and success messages since you can alse send content from your controller. Then you would send an array with values instead of true.
Blade template
<div class="container">
#if($breadcrumb)
<div class="breadcrumb-container">
<ul class="breadcrumb">
#section('breadcrumbs')
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
#endif
</div>
You can check the URI to see if you want to display it or not. It's logic in your view which is usually frowned upon, but it's the easiest way I can come up with.
<div class="container">
<div class="breadcrumb-container">
<ul class="breadcrumb">
#if(Route::uri() == '/')
<li class="last-breadcrumb">
About
</li>
#endif
<li>
<a href="/homepage/" title="homepage">
homepage
</a>
</li>
#show
</ul>
</div>
</div>
Depending on the URI you are using for your home page, you may need to tweak the condition.
If you use #yield in your master template then it will only display content when the section has been defined. #content requires the section to be always defined.

undefined variable in codeigniter php

I am new to codeigniter, From My senior i got one task to solve existing undone internal project. and develop that project again.
i am having query when i am ruinning this project.
here i am pasting my 2 view files.
tell me if any one required further files.
Thank you in advanced.
TODO DropDown View
<!-- BEGIN TODO DROPDOWN -->
<?php
if (isset($pendingtask)) {
?>
<li class="dropdown" id="header_task_bar">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
<i class="icon-tasks"></i>
<span class="badge"><?php echo count($pendingtask); ?></span>
</a>
<ul class="dropdown-menu extended tasks">
<li>
<p>You have <?php echo count($pendingtask); ?> pending tasks</p>
</li>
<li>
<ul class="dropdown-menu-list scroller" style="height:250px">
<?php
if (!empty($pendingtask)) {
foreach ($pendingtask as $task_row) {
?>
<li>
<a href="<?php echo base_url(); ?>milestone/viewMilestone/<?php echo $task_row->id; ?>">
<span class="task">
<span class="desc"><?php echo $task_row->title; ?></span>
<span class="percent">30%</span>
</span>
<span class="progress progress-success ">
<span style="width: 30%;" class="bar"></span>
</span>
</a>
</li>
<?php
}
}
?>
</ul>
</li>
<li class="external">
See all tasks <i class="m-icon-swapright"></i>
</li>
</ul>
</li>
<!-- END TODO DROPDOWN -->
<?php } ?>
pagetopnavigation view
<!-- BEGIN HEADER -->
<div class="header navbar navbar-inverse navbar-fixed-top">
<!-- BEGIN TOP NAVIGATION BAR -->
<div class="navbar-inner">
<div class="container-fluid">
<?php $this->load->view('include/pagelogo'); ?>
<!-- BEGIN TOP NAVIGATION MENU -->
<ul class="nav pull-right">
<?php //$this->load->view('include/pagetopnotifications'); ?>
<?php //$this->load->view('include/pagetopnewmessage'); ?>
<?php $this->load->view('include/pagetoptodo', $pendingtask); ?>
<?php $this->load->view('include/pagetopuserprofile'); ?>
</ul>
<!-- END TOP NAVIGATION MENU -->
</div>
</div>
<!-- END TOP NAVIGATION BAR -->
</div>
<!-- END HEADER -->
?php $this->load->view('include/pagetoptodo', $pendingtask); ?>
is where your error is: the second parameter needs to be an array. So:
?php $this->load->view('include/pagetoptodo', array('pendingtask'=>$pendingtask)); ?>
in order to pass to a sub-view
In Your pagetopnavigation view page you used the variable "$pendingtask"
(<?php $this->load->view('include/pagetoptodo', $pendingtask); ?>)
The error what you are getting is a Notice => it is saying the variable($pendingtask) is not defined in your code ; it will not stop the execution of file, you can stop "Notice and Warning" messages by using error_reporting method or you can set up this in Codeigniter configurations, check this link for reference : http://phpdog.blogspot.in/2012/02/codeigniter-error-reporting-handling.html

Categories