How to add schema markup on dynamic codeigniter pages - codeigniter

I want to add schema markup on dynamically created codeigniter pages. as per my understanding you can add schema to optimize SEO search results and it can be added in header file. But i have dynamically created pages which shows different category pages and i need to add scheme for all those category pages.
Problem is how to add different schema for multiple pages if there is only one header for all pages.
Here is the view page code:
<?php
$this->load->view("landing/header");
?>
<div class="container" >
<?php
for ($i = 0; $i < count($services); $i = $i + 3) {
?>
<div class="row <?= (($i != 0) && ($i != (count($services) - 1))) ? 'sm-pad-v' : '' ?>">
<?php
for ($j = 0; $j < 3; $j++) {
if (isset($services[$i + $j])) {
?>
<div class="col-md-4 assignment-content">
<h3>
<strong>
<?= $services[$i + $j]->service_name; ?>
</strong>
</h3>
<p>
<?= trimText(strip_tags($services[$i + $j]->description), 150) ?>
<a class="" href="<?= base_url($services[$i + $j]->seo_url) ?>"><span class="read-more">read more</span></a>
</p>
</div>
<?php
}
}
?>
</div>
<?php
}
?>
</div>
Here is the code for schema markup:
<script type="application/ld+json">
{
"#context" : "http://schema.org",
"#type" : "Organization",
"name" : "Programming Assignment Help",
"alternateName" : "AJAX Programing Assignment Help",
"url" : "https://www.assignment.com/"
}
<script type="application/ld+json">
{
"#context" : "http://schema.org",
"#type" : "Organization ",
"url" : "https://www.Assignment.com/",
"logo" : "https://www.assignmenthelp.com/assets/img/logo-p-lite.png ",
"contactPoint" : [
{ "#type" : "ContactPoint",
"email" : "support#Assignment.com",
"URL" : "https://www.Assignment.com/contact-us",
"contactType" : "customer service"
}]
}
<script type="application/ld+json">
{
"#context": "http://schema.org/",
"#type": "Organization",
"name": "AJAX Programming Assignment Help",
"image": "https://www.Assignment.com/uploads/1559752385394.jpg",
"aggregateRating": {
"#type": "AggregateRating",
"ratingValue": "4.9",
"ratingCount": "5500"
}
}
</script>

Related

change URL parameter in Codeignitor

I'm trying to change the URL parameter from the row ID to the NAME of the article. here is my code
Controllers
public function view($id=0)
{
if( !isset($id) || !is_numeric($id) ) {
redirect(base_url());
}
$tot = $this->Model_service->service_check($id);
if(!$tot) {
redirect(base_url());
}
and the view is
<?php
foreach ($services as $row) {
?>
<div class="col-lg-4 col-md-6">
<div class="services-item effect-item">
<a href="<?php echo base_url(); ?>service/<?php echo $row['name']; ?>" class="image-effect">
<div class="services-photo" style="background-image: url(<?php echo base_url(); ?>public/uploads/<?php echo $row['photo']; ?>)"></div>
</a>
<div class="services-text">
<h3><?php echo $row['name']; ?></h3>
<p>
<?php echo nl2br($row['short_description']); ?>
</p>
<div class="button-bn">
<?php echo READ_MORE; ?> <i class="fa fa-chevron-circle-right"></i>
please help me with the most simplified answer thank you
Yo need to change your article view function in controller. Lookup article name instead of id. But name might contains spaces which is not URL friendly so using concept of slug will solve this.
public function view($slug='')
{
if($slug == '') {
redirect(base_url());
}
$tot = $this->Model_service->find_service_by_slug($slug);
if(!$tot) {
redirect(base_url());
}
Reference link for concept of slug is https://codeigniter.com/user_guide/tutorial/news_section.html

Codeigniter Repotrs page problem with dates

I am developing a project using Codeigniter framework and in the reports page i need to have a form that has datatables structure so i can generate reports by day,month and year. but i dont know how to use datatables.
i have tried to add code like for example where it was written Y-m i added d-m-y but it doesn't work
Reports Controller:
defined('BASEPATH') OR exit('No direct script access allowed');
class Reports extends Admin_Controller
{
public function __construct()
{
parent::__construct();
$this->data['page_title'] = 'Stores';
$this->load->model('model_reports');
}
/*
* It redirects to the report page
* and based on the year, all the orders data are fetch from the database.
*/
public function index()
{
if(!in_array('viewReports', $this->permission)) {
redirect('dashboard', 'refresh');
}
$today_year = date('Y');
if($this->input->post('select_year')) {
$today_year = $this->input->post('select_year');
}
$parking_data = $this->model_reports->getOrderData($today_year);
$this->data['report_years'] = $this->model_reports->getOrderYear();
$final_parking_data = array();
foreach ($parking_data as $k => $v) {
if(count($v) > 1) {
$total_amount_earned = array();
foreach ($v as $k2 => $v2) {
if($v2) {
$total_amount_earned[] = $v2['net_amount'];
}
}
$final_parking_data[$k] = array_sum($total_amount_earned);
}
else {
$final_parking_data[$k] = 0;
}
}
$this->data['selected_year'] = $today_year;
$this->data['company_currency'] = $this->company_currency();
$this->data['results'] = $final_parking_data;
$this->render_template('reports/index', $this->data);
}
}
**Reports Model:**
<?php
class Model_reports extends CI_Model
{
public function __construct()
{
parent::__construct();
}
/*getting the total months*/
private function months()
{
return array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
}
/* getting the year of the orders */
public function getOrderYear()
{
$sql = "SELECT * FROM orders WHERE paid_status = ?";
$query = $this->db->query($sql, array(1));
$result = $query->result_array();
$return_data = array();
foreach ($result as $k => $v) {
$date = date('Y', $v['date_time']);
$return_data[] = $date;
}
$return_data = array_unique($return_data);
return $return_data;
}
// getting the order reports based on the year and moths
public function getOrderData($year)
{
if($year) {
$months = $this->months();
$sql = "SELECT * FROM orders WHERE paid_status = ?";
$query = $this->db->query($sql, array(1));
$result = $query->result_array();
$final_data = array();
foreach ($months as $month_k => $month_y) {
$get_mon_year = $year.'-'.$month_y;
$final_data[$get_mon_year][] = '';
foreach ($result as $k => $v) {
$month_year = date('Y-m', $v['date_time']);
if($get_mon_year == $month_year) {
$final_data[$get_mon_year][] = $v;
}
}
}
return $final_data;
}
}
}
**View index**
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Reports
</h1>
<ol class="breadcrumb">
<li><i class="fa fa-dashboard"></i> Home</li>
<li class="active">Reports</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-md-12 col-xs-12">
<form class="form-inline" action="<?php echo base_url('reports/') ?>" method="POST">
<div class="form-group">
<label for="date">Year</label>
<select class="form-control" name="select_year" id="select_year">
<?php foreach ($report_years as $key => $value): ?>
<option value="<?php echo $value ?>" <?php if($value == $selected_year) { echo "selected"; } ?>><?php echo $value; ?></option>
<?php endforeach ?>
</select>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<br /> <br />
<div class="col-md-12 col-xs-12">
<?php if($this->session->flashdata('success')): ?>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<?php echo $this->session->flashdata('success'); ?>
</div>
<?php elseif($this->session->flashdata('error')): ?>
<div class="alert alert-error alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<?php echo $this->session->flashdata('error'); ?>
</div>
<?php endif; ?>
<div class="box">
<div class="box-header">
<h3 class="box-title">Total - Report</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<div class="chart">
<canvas id="barChart" style="height:250px"></canvas>
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
<div class="box">
<div class="box-header">
<h3 class="box-title">Total Paid Orders - Report Data</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<table id="datatables" class="table table-bordered table-striped">
<thead>
<tr>
<th>Month - Year</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<?php foreach ($results as $k => $v): ?>
<tr>
<td><?php echo $k; ?></td>
<td><?php
echo $company_currency .' ' . $v;
//echo $v;
?></td>
</tr>
<?php endforeach ?>
</tbody>
<tbody>
<tr>
<th>Total Amount</th>
<th>
<?php //echo $company_currency . ' ' . array_sum($parking_data); ?>
<?php echo array_sum($results); ?>
</th>
</tr>
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<!-- col-md-12 -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<script type="text/javascript">
$(document).ready(function() {
$("#reportNav").addClass('active');
});
var report_data = <?php echo '[' . implode(',', $results) . ']'; ?>;
$(function () {
/* ChartJS
* -------
* Here we will create a few charts using ChartJS
*/
var areaChartData = {
labels : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label : 'Electronics',
fillColor : 'rgba(210, 214, 222, 1)',
strokeColor : 'rgba(210, 214, 222, 1)',
pointColor : 'rgba(210, 214, 222, 1)',
pointStrokeColor : '#c1c7d1',
pointHighlightFill : '#fff',
pointHighlightStroke: 'rgba(220,220,220,1)',
data : report_data
}
]
}
//-------------
//- BAR CHART -
//-------------
var barChartCanvas = $('#barChart').get(0).getContext('2d')
var barChart = new Chart(barChartCanvas)
var barChartData = areaChartData
barChartData.datasets[0].fillColor = '#00a65a';
barChartData.datasets[0].strokeColor = '#00a65a';
barChartData.datasets[0].pointColor = '#00a65a';
var barChartOptions = {
//Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
scaleBeginAtZero : true,
//Boolean - Whether grid lines are shown across the chart
scaleShowGridLines : true,
//String - Colour of the grid lines
scaleGridLineColor : 'rgba(0,0,0,.05)',
//Number - Width of the grid lines
scaleGridLineWidth : 1,
//Boolean - Whether to show horizontal lines (except X axis)
scaleShowHorizontalLines: true,
//Boolean - Whether to show vertical lines (except Y axis)
scaleShowVerticalLines : true,
//Boolean - If there is a stroke on each bar
barShowStroke : true,
//Number - Pixel width of the bar stroke
barStrokeWidth : 2,
//Number - Spacing between each of the X value sets
barValueSpacing : 5,
//Number - Spacing between data sets within X values
barDatasetSpacing : 1,
//String - A legend template
legendTemplate : '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
//Boolean - whether to make the chart responsive
responsive : true,
maintainAspectRatio : true
}
barChartOptions.datasetFill = false
barChart.Bar(barChartData, barChartOptions)
})
</script>

session destrioyed on add to cart in laravel

I am using laravel5. I need to add the product into cart. when i add a new product it is add into cart item as 1. but when refresh the page or move to next page my cart item count destroyed. Here i attach my coding. Please help me what is my mistake. i am new to laravel
Controller:
public function cart($request)
{
$quick=Mainpage::get_quick(5);
$logo = Mainpage::get_image();
$result_cart = Mainpage::get_add_to_cart_details();
$session_result = '';
// if(Session::get('cus_id'))
// {
// $navbar = View::make('layout.header');
// }
// else
// {
// $navbar = View::make('layout.header');
// }
return view('cart', ['logo' => $logo, 'quick' =>$quick,'session_result'=>$session_result,'result_cart'=>$result_cart]);
}
Model:
public static function get_add_to_cart_details()
{
$get_pro_dea = "";
if(isset($_SESSION['cart'])){
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
$pid=$_SESSION['cart'][$i]['product_id'];
//$pname="Have to get";
$get_pro_dea[$pid] = DB::table('le_product')->where('product_id',$pid)->get();
}
}
else
{
$get_pro_dea[0] = array();
}
return $get_pro_dea;
}
View:(header.blade.php):
<div class="col-sm-4" style="margin-top:17px">
<div class="cart box_1 pull-right">
<a href="<?php echo url('cart'); ?>">
<?php if(isset($_SESSION['cart']))
{
$item_count_header1 = count($_SESSION['cart']);
}
else {
$item_count_header1 = 0;
}
$item_count_header = $item_count_header1;
if($item_count_header != 0)
{
?>
<img src='<?php echo url(); ?>/assets/images/shopping-cart.png' alt=''><span style='color:black;
'> ( <?php echo $item_count_header; ?> Items) </span>
<?php
}
else
{ ?>
<img src="<?php echo url(); ?>/assets/images/shopping-cart.png" alt=""><span style="color:black;"> (card empty)</span>
<?php }
?>
</strong>
</a>
</div>
</div>
</div>
<?php } ?>
</div>

Dynatable.js remove an element from a stylized list and update count

I am using for the most part the default code from the dynatable website for a stylized list.
I really like it as i get search on all my fields. here is the html code and the javascript code:
<ul id="ul-example" class="row-fluid no-bullets">
<?php foreach ($dms as $k => $v): ?>
<li class="span12" data-color="gray" id="manage_vehicle_id_<?= $v['id'];?>">
<div class="thumbnail">
<div class="thumbnail-image">
<center>
<img src="<?= $v['image']; ?>" width="220" height="180" />
</center>
</div>
<div class="caption">
<center>
<h5><?= $v['year'] . ' ' . $v['make'] . ' ' . $v['model'] . ' ' . $v['trim'];?></h5>
</center>
<hr>
<center>
<p><b>Vin:</b> <?= $v['vin']; ?></p>
<p><b>Stock #:</b> <?= $v['stock'];?></p>
</center>
<hr>
<p>
<center>
<button class="btn btn-primary" onclick="getVehicleDetailsByid('<?= $v['id']; ?>');"><i class="fa fa-edit"></i> Edit</button>
<button class="btn btn-danger" onclick="openDeleteVehicleByIdModal('<?= $v['id']; ?>', '<?= $v['vin']; ?>', '<?= $v['stock'];?>');"><i class="fa fa-minus"></i> Delete</button>
</center>
</p>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>
function ulWriter(rowIndex, record, columns, cellWriter) {
var cssClass = "span12", li;
if (rowIndex % 3 === 0) { cssClass += ' first'; }
li = '<li class="' + cssClass + '" id="'+record.id+'" data-row-index="'+rowIndex+'"><div class="thumbnail"><div class="thumbnail-image">' + record.thumbnail + '</div><div class="caption">' + record.caption + '</div></div></li>';
return li;
}
// Function that creates our records from the DOM when the page is loaded
function ulReader(index, li, record) {
var $li = $(li),
$caption = $li.find('.caption');
record.thumbnail = $li.find('.thumbnail-image').html();
record.caption = $caption.html();
record.label = $caption.find('h5').text();
record.description = $caption.find('p').text();
record.color = $li.data('color');
record.id = $li.attr('id');
record.index = $li.attr('data-row-index');
}
$( '#ul-example' ).dynatable({
table: {
bodyRowSelector: 'li'
},
writers: {
_rowWriter: ulWriter
},
readers: {
_rowReader: ulReader
},
features: {
paginate: false,
sort: true,
search: true,
recordCount: true,
perPageSelect: false
},
inputs: {
searchTarget: '#manage_vehicle_search',
recordCountTarget: '#manage_vehicle_recordCount'
}
});
as you can see in the html i have a delete button that removes the record. I can remove it manually. However it is not actually removed. When a search query happens the item is still in the list.
I remove it with:
$( '#manage_vehicle_id_'+id ).remove();
var dynatable = $('#ul-example').data('dynatable');
dynatable.domColumns.removeFromArray(index);
dynatable.dom.update();
I am getting an error here something like column.length is null. I can see the this.remove method in dynatable is throwing an error.
How can i remove this item from the list and update dynatable dom and the get the right count?
Thanks
I solved this issue by using dynatable.process() instead of remove/update. Not sure if it's the proper solution, but it worked for me.
$( '#manage_vehicle_id_'+id ).remove();
var dynatable = $('#ul-example').data('dynatable');
dynatable.process();

Why do I get HTTP Error when trying to upload with uploadify

I chose gallerycms to build my own gallery but when I try to make it as module into my codeigniter cms I get this error HTTP Error. I don't know why I see this error although I was copying all controllers, models, views, core files and I still get this error.
NOTICE: uploadify work good with Gallerycms but when I want to add it into my cms as a module I get this error:
firebug code
<script type="text/javascript">
$(document).ready(function() {
$('.btn-group > a').tooltip();
$('#upload-btn').hide();
$('#new-images').hide();
$('a.img-fancy').fancybox();
$('.image-delete-btn').click(function() {
deleteUrl = $(this).attr('action');
});
$('#image-modal').on('show', function() {
$('#image-modal-delete-btn').attr('href', deleteUrl);
});
$("#sortable").sortable({
handle : '.drag-handle',
update : function () {
var order = $('#sortable').sortable('serialize', { key : 'order_num[]' });
$.ajax({
url : 'http://localhost/gallery/album/reorder?' + order,
type : 'GET',
cache : false,
success : function(response) {
$('#reorder-feedback').show();
$('#reorder-feedback').html('<a class="close" data-dismiss="alert">x</a><strong>Changed image order successfully.</strong>');
},
error : function(jqXHR, textStatus, errorThrown) {
alert('An error occured when ordering the images.');
}
});
}
});
$( "#sortable" ).disableSelection();
$('#file_upload').uploadify({
'uploader' : 'http://localhost/gallery/webroot/flash/uploadify.swf',
'script' : 'http://localhost/gallery/api/upload/3',
'cancelImg' : 'http://localhost/gallery/webroot/images/cancel.png',
'folder' : '/webroot/uploads',
'auto' : false,
'multi' : true,
'fileExt' : '*.jpg;*.jpeg;*.gif;*.png',
'fileDesc' : 'Image files',
'sizeLimit' : 2097152, // 2MB
'wmode' : 'opaque',
'onSelect' : function(event, ID, fileObj) {
$('#upload-btn').show();
},
'onCancel' : function(event, ID, fileObj) {
$('#upload-btn').hide();
},
'onError' : function(event, ID, fileObj, errorObj) {
},
'onComplete' : function(event, ID, fileObj, response, data) {
var fileName = response;
$('#upload-btn').hide();
$('#new-images').show();
$.ajax({
url : 'http://localhost/gallery/album/resize/3/' + response,
type : 'POST',
cache : false,
success : function(response) {
if (response !== 'failure') {
var new_image = '<li><img src="http://localhost/gallery/webroot/uploads/' + response + '" /><br />' + response + '</li>';
$('#new-image-list').append(new_image);
} else {
var fail_message = '<li>Thumbnail creation failed for: ' + fileObj.name + '</li>';
$('#new-image-list').append(fail_message);
}
},
error : function(jqXHR, textStatus, errorThrown) {
alert('Error occurred when generating thumbnails.');
}
});
}
});
});
</script>
api controller
/**
* Handles image uploads.
*
* #param type $album_id
*/
public function upload($album_id)
{
$config = array();
$config['upload_path'] = './webroot/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '2048'; // 2MB
$config['remove_spaces'] = TRUE;
$config['encrypt_name'] = TRUE;
$config['overwrite'] = FALSE;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('Filedata'))
{
header('HTTP/1.1 500 Internal Server Error');
exit();
}
else
{
$upload_info = $this->upload->data();
$album_config = $this->config_model->get_by_album_id($album_id);
// Insert file information into database
$now = date('Y-m-d H:i:s');
$order_num = $this->image_model->get_last_order_num($album_id);
if (empty($order_num))
{
$order_num = 0;
}
$order_num++;
$image_data = array(
'album_id' => $album_id,
'uuid' => $this->create_uuid(),
'name' => $upload_info['file_name'],
'order_num' => $order_num,
'caption' => '',
'raw_name' => $upload_info['raw_name'],
'file_type' => $upload_info['file_type'],
'file_name' => $upload_info['file_name'],
'file_ext' => $upload_info['file_ext'],
'file_size' => $upload_info['file_size'],
'path' => $config['upload_path'],
'full_path' => $upload_info['full_path'],
'published' => $album_config->auto_publish,
'created_at' => $now,
'updated_at' => $now,
);
$image_id = $this->image_model->create($image_data);
$this->album_model->update(array('updated_at' => $now), $album_id);
echo $image_id;
}
}
}
views/images.php
<?php
$includes = array(
'js' => array('jquery-ui-1.8.18.custom.min.js', 'swfobject.js', 'jquery.uploadify.v2.1.4.min.js', 'fancybox/jquery.fancybox-1.3.4.pack.js'),
'css' => array('uploadify.css', 'fancybox/jquery.fancybox-1.3.4.css'));
?>
<?php $this->load->view('album/inc/header', $includes); ?>
<?php if (isset($flash)): ?>
<div class="alert alert-success"><a class="close" data-dismiss="alert">x</a><strong><?php echo $flash; ?></strong></div>
<?php endif; ?>
<div class="w100" style="margin-bottom: 10px;">
<ul class="pager">
<li class="previous">
← Back to albums
</li>
</ul>
<div class="well">
<h4 style="margin-bottom: 10px;">Upload images for album: <?php echo $album->name; ?></h4>
<input id="file_upload" type="file" name="file_upload" />
<p id="upload-btn" style="margin:10px 0;">
Upload Files
</p>
<div id="new-images">
<h4>Uploaded Images</h4>
<p><a class="btn" href="<?php echo site_url("album/images/$album->id"); ?>" style="margin: 10px 0;"><i class="icon-refresh"></i> Refresh</a></p>
<ul id="new-image-list"></ul>
<div class="clear"></div>
</div>
</div>
</div>
<div id="reorder-feedback" class="alert alert-success" style="display: none;"></div>
<span class="left w75">
<?php
$total_file_size = 0;
$total_images = 0;
$img_url = '';
?>
<?php if (isset($images)): ?>
<ul id="sortable">
<?php foreach ($images as $image): ?>
<?php
$total_file_size += $image->file_size;
$total_images++;
$img_url = base_url() . 'webroot/uploads/' . $image->file_name;
?>
<li id="image_<?php echo $image->id; ?>" class="ui-state-default" style="height: <?php echo $config->thumb_height + 10; ?>px">
<div class="drag-handle" style="height: <?php echo $config->thumb_height + 5; ?>px"></div>
<div class="image-container">
<a class="album-images img-fancy thumbnail" href="<?php echo $img_url; ?>" title="<?php echo $image->caption; ?>">
<img src="<?php echo base_url() . 'webroot/uploads/' . $image->raw_name . '_thumb' . $image->file_ext . '?r=' . rand(); ?>" alt="<?php echo $image->caption; ?>" />
</a>
</div>
<div class="info" style="left: <?php echo $config->thumb_width + 50; ?>px">
File name: <?php echo $image->name; ?><br />
Caption:
<?php if (empty($image->caption)): ?>
Create one
<?php else: ?>
<?php echo $image->caption; ?>
<?php endif; ?>
<br />
<?php /* Comments: <?php echo $image->comments; ?><br /> */ ?>
File size: <?php echo $image->file_size; ?> KB<br />
</div>
<div class="btn-group">
<i class="icon-zoom-in"></i>
<i class="icon-download-alt"></i>
<i class="icon-pencil"></i>
<?php /* <i class="icon-comment"></i> */ ?>
<?php if ($image->published == 1): ?>
<i class="icon-ok icon-white"></i>
<?php else: ?>
<i class="icon-ok"></i>
<?php endif; ?>
<i class="icon-remove icon-white"></i>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</span>
<span class="right w20">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header"><?php echo $album->name; ?></li>
<li><i class="icon-pencil"></i>Rename</li>
<li><i class="icon-cog"></i>Configure</li>
<li class="nav-header">Info</li>
<li>Images: <?php echo $total_images; ?></li>
<li>Album file size: <?php echo round($total_file_size / 1024, 2); ?> MB</li>
</ul>
</div>
</span>
<div class="clear"></div>
<div class="modal hide fade" id="image-modal">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Delete Image</h3>
</div>
<div class="modal-body">
<p><strong>Are you sure you want to delete this image?</strong></p>
</div>
<div class="modal-footer">
<a id="image-modal-delete-btn" href="#" class="btn btn-danger">Delete</a>
Cancel
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('.btn-group > a').tooltip();
$('#upload-btn').hide();
$('#new-images').hide();
$('a.img-fancy').fancybox();
$('.image-delete-btn').click(function() {
deleteUrl = $(this).attr('action');
});
$('#image-modal').on('show', function() {
$('#image-modal-delete-btn').attr('href', deleteUrl);
});
$("#sortable").sortable({
handle : '.drag-handle',
update : function () {
var order = $('#sortable').sortable('serialize', { key : 'order_num[]' });
$.ajax({
url : '<?php echo base_url(); ?>album/reorder?' + order,
type : 'GET',
cache : false,
success : function(response) {
$('#reorder-feedback').show();
$('#reorder-feedback').html('<a class="close" data-dismiss="alert">x</a><strong>Changed image order successfully.</strong>');
},
error : function(jqXHR, textStatus, errorThrown) {
alert('An error occured when ordering the images.');
}
});
}
});
$( "#sortable" ).disableSelection();
$('#file_upload').uploadify({
'uploader' : '<?php echo base_url(); ?>webroot/flash/uploadify.swf',
'script' : '<?php echo base_url(); ?>album/api/upload/<?php echo $album->id; ?>',
'cancelImg' : '<?php echo base_url(); ?>webroot/images/cancel.png',
'folder' : '/webroot/uploads',
'auto' : false,
'multi' : true,
'fileExt' : '*.jpg;*.jpeg;*.gif;*.png',
'fileDesc' : 'Image files',
'sizeLimit' : 2097152, // 2MB
'wmode' : 'opaque',
'onSelect' : function(event, ID, fileObj) {
$('#upload-btn').show();
},
'onCancel' : function(event, ID, fileObj) {
$('#upload-btn').hide();
},
'onError' : function(event, ID, fileObj, errorObj) {
},
'onComplete' : function(event, ID, fileObj, response, data) {
var fileName = response;
$('#upload-btn').hide();
$('#new-images').show();
$.ajax({
url : '<?php echo base_url(); ?>album/resize/<?php echo $album->id; ?>/' + response,
type : 'POST',
cache : false,
success : function(response) {
if (response !== 'failure') {
var new_image = '<li><img src="<?php echo base_url(); ?>webroot/uploads/' + response + '" /><br />' + response + '</li>';
$('#new-image-list').append(new_image);
} else {
var fail_message = '<li>Thumbnail creation failed for: ' + fileObj.name + '</li>';
$('#new-image-list').append(fail_message);
}
},
error : function(jqXHR, textStatus, errorThrown) {
alert('Error occurred when generating thumbnails.');
}
});
}
});
});
</script>
I am not sure if this will help or not.
I ran into the same problem before,
then I realized when I uploaded the files to the server,
I was logged in as root user so the file owner is root.
The solution was to remove all uploaded files, then upload again using other user.
Now it's working well.
Hope that's work for you.
the problem with files extensions so i replaced this code
$config['allowed_types'] = 'gif|jpg|png';
with
$config['allowed_types'] = '*';
then i selected only extension i prefered from jquery code
'fileExt' : '*.jpg;*.jpeg;*.gif;*.png',
You can modify mime in application/config/mimes.php
Change:
'jpeg' => array('image/jpeg', 'image/pjpeg'),
'jpg' => array('image/jpeg', 'image/pjpeg'),
'jpe' => array('image/jpeg', 'image/pjpeg'),
'png' => array('image/png', 'image/x-png'),
To
'jpeg' => array('image/jpeg', 'image/pjpeg', 'application/octet-stream'),
'jpg' => array('image/jpeg', 'image/pjpeg', 'application/octet-stream'),
'jpe' => array('image/jpeg', 'image/pjpeg', 'application/octet-stream'),
'png' => array('image/png', 'image/x-png', 'application/octet-stream'),
It's should work :)
You did not provide us a detailed error. HTTP Error could mean many things.
1. Check your Firebug Console or Chrome Console for the Ajax POST and
see what it returns.
2. Make sure the folder the uploads save to is writable (CHMOD
Permissions).
One thing that catches my eye is:
$config['upload_path'] = './webroot/uploads/';
it looks like you have copy pasted this, make sure you give it a proper upload path.

Resources