How to spilt tabs jquery file with codeigniter? - php

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.

Related

create master page layout in codeigniter master-page layout

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

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') ?>

Where can I find the file PHP is fetching text/table from?

I recently inherited a website with a horrible file structure. I need to update some content (text) but I can’t find where it is being defined. The database table does not have the information, so I'm guessing the text is being defined elsewhere. Is there a tool or "trick" in Chrome Dev Tools to find the content source? Your help is much appreciated!
***Snippet from PHP File:
<div id="product_wrapper" class="add-bottom30">
<div class="columns sixteen">
<div class="columns twelve add-bottom60 catalogue">
<!-- Pager -->
<?php include('sql-' . $_SESSION['lang'] . '/promos.php');?>
</div>
<div class="columns four side">
<h5 style="margin-bottom:25px;">FLYERS</h5>
<ul>
<li style="background-color:#0065a4;">
<?php echo flyer_jet_2016; (where the text I need to change lives) ?>
</li>
</ul>
</div>
<div class="clear"><!-- ClearFix --></div>
</div>
</div>
*** Snippet from source code ("View Source" in Chrome):
<div class="columns four side">
<h5 style="margin-bottom:25px;">FLYERS</h5>
<ul>
<li style="background-color:#0065a4;">
<span class="icon" data-icon="(" style="color:#fff;margin-bottom:15px;"></span><br>Tool Storage<br>Solutions 2016
</li>
</ul>
</div>
<div class="clear"><!-- ClearFix --></div>
</div>

Applying PHP inside multiple divs

well, I have been trying to implement my PHP inside multiple divs but somehow my CSS gets messed up and the records start to display diagonally i.e first record displays correctly and then the rest of the records starts displaying from the end of their previous record (that can be viewed when scrolling right). Which is very annoying. What I'm trying to achieve is: To position my divs OR PHP in such a way that my CSS does not get disturbed, is this possible? Here's my PHP code for the particular data, any help would be appreciated.
<?php
$result1 = mysql_query("SELECT *from `movie_schedule`");
if(mysql_num_rows($result1))
{while($row2 = mysql_fetch_array($result1, MYSQL_BOTH))
{
?>
<div id="event" class="content-event">
<!-- container -->
<div class="container">
<h3>Show Times</h3>
<div class="event-grids">
<div class="col-md-3 event-grid">
<div class="pic"> </div>
<ul>
<li class="hedding"><?php print($row2['Movie_ID']); ?> <?php print($row2['Movie_Name']); ?></li>
<li class="date"><?php print($row2['Movie_Date']); ?></li>
</ul>
<div class="clearfix"> </div>
</div>
<div class="col-md-4 event-grid small-text">
<p><br><?php print($row2['Show_Time']); ?></p>
</div>
<div class="col-md-2 event-grid large-text">
<p class="text"><?php print($row2['Movie_Cost']); ?></p>
</div>
<div class="col-md-3 event-grid text-button">
<ul>
<li class="num"><?php print($row2['Movie_ID']); ?></li>
<li class="button yellow">Remove</li>
</ul><br><br>
<?php
}}
?>
</div>
</div>
</div>
It's not the CSS that's messing up. You're ending your loop before you close all of your elements properly inside a single block. You open the loop with a div, and you end it with an ul.
You can actually view the nested elements using a page inspector. In Chrome or Firefox, for example, this is achieved by right-clicking the page and selecting "Page inspector".
Try closing all your elements properly before closing your loop.
You are messing up with closing </div>
<?php
$result1 = mysql_query("SELECT *from `movie_schedule`");
if(mysql_num_rows($result1))
{
while($row2 = mysql_fetch_array($result1, MYSQL_BOTH))
{?>
<div id="event" class="content-event">
<div class="container">
<h3>Show Times</h3>
<div class="event-grids">
<div class="col-md-3 event-grid">
<div class="pic"> </div>
<ul>
<li class="hedding"><?php print($row2['Movie_ID']); ?> <?php print($row2['Movie_Name']); ?></li>
<li class="date"><?php print($row2['Movie_Date']); ?></li>
</ul>
<div class="clearfix"> </div>
</div>
<div class="col-md-4 event-grid small-text">
<p><br><?php print($row2['Show_Time']); ?></p>
</div>
<div class="col-md-2 event-grid large-text">
<p class="text"><?php print($row2['Movie_Cost']); ?></p>
</div>
<div class="col-md-3 event-grid text-button">
<ul>
<li class="num"><?php print($row2['Movie_ID']); ?></li>
<li class="button yellow">Remove</li>
</ul>
<br><br>
</div>
</div>
</div>
</div>
<?php}}?>

Why is PJAX stopping Nestable working?

I have 3 columns in my app. Each column has an unordered list. I am using Nestable to drag and drop list items between lists. The mark up is as follows:
<div class="row-fluid span12">
<div class="cf nestable-lists">
<div id="pjax-content">
<div class="span4">
<div class="dd" id="nestable1">
<ul class="dd-list">
<li class="dd-item dd3-item" data-id="123">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
<li class="dd-item dd3-item" data-id="456">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
</ul>
</div>
</div>
<div class="span4">
<div class="dd" id="nestable2">
<ul class="dd-list">
<li class="dd-item dd3-item" data-id="789">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
<li class="dd-item dd3-item" data-id="1011">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
</ul>
</div>
</div>
<div class="span4">
<div class="dd" id="nestable3">
<ul class="dd-list">
<li class="dd-item dd3-item" data-id="1213">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
<li class="dd-item dd3-item" data-id="1415">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
This works and I can drag and drop list items between each list. The problem is when I implement PJAX.
I have a few links that use PJAX to change the url i.e. each link will update the data or order of the data in each list based on the URL. The data updates within id="pjax-content" accordingly, so it works. This is a snippet of the server side code (using CI):
if (isset($_SERVER["HTTP_X_PJAX"])) {
echo $data['contents'];
} else {
// construct views when not PJAX
}
$data['contents'] contains the html as a string.
I have the following JS libraries too (I have tried removing some of these and the problem still exists):
<script type="text/javascript" src="jquery-1.9.0.js"></script>
<script type="text/javascript" src="bootstrap.js"></script>
<script type="text/javascript" src="nestable.js"></script>
<script type="text/javascript" src="nestable-settings.js"></script>
<script type="text/javascript" src="bootstrap-editable.js"></script>
<script type="text/javascript" src="jquery.cookie.js"></script>
<script type="text/javascript" src='jquery.pjax.js'></script>
<script type="text/javascript">
$(document).pjax('[data-pjax] a, a[data-pjax]', '#pjax-content');
$(document).on('pjax:send', function() {
console.log("before send");
});
$(document).on('pjax:complete', function() {
console.log("done!");
});
</script>
The Problem
When I click on one of the links PJAX works, the data is updated, the page doesn't reload and the console shows before send and done - so all is well. However, the nestable items are no longer selectable so a I can't drag and drop them. When I do a full page refresh it works and I can drag and drop.
I have compared the markup before and after (as that was a previous issue) and everything is the same.
Any suggestions on where I am going wrong? Or how to best debug this?
call nestable after your ajax complete function
$(document).on('pjax:complete', function() {
$('#nestable1,#nestable2,#nestable3').nestable();
});

Categories