⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Problem with image crud



teoj

teoj
  • profile picture
  • Member

Posted 21 July 2013 - 10:28 AM

Hellow all im trying do works image crud from a action from grocery crud, i show you my code:

 

Controller:

 

function view_fotos($id = null)
    {
        $this->load->library('image_crud');
        $image_crud = new image_crud();


        $image_crud->set_table('photos');


       
        $image_crud
->set_primary_key_field('id');


        $image_crud->set_url_field('url')
        ->set_image_path('assets/uploads')
        -> set_relation_field('inmueble_ID')
        ->set_title_field('title');


        $output = $image_crud->render();
     // load_plantilla load a template
        $this -> load_plantilla('layout',  $output, 'fotos_view');
    }


function load_plantilla ($layout, $output,  $content)
    {
$this->template
            ->set_partial('head', 'template/head')
            ->set_partial('header', 'template/header')
            ->set_partial('subheader', 'template/subheader')
            ->set_partial('latizq', 'template/latizq')
            ->set_partial('content', $content)
            ->set_partial('subfooter', 'template/subfooter')
            ->set_partial('footer', 'template/footer')
            ->set_partial('foot', 'template/foot')
            ->build($layout, $output);
}
 
and the view is:
 
<?php
echo $output
;
?>

 

 

well when i look the code from the google chrome this apear:

 

 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    <title></title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link rel="stylesheet" href="http://xxxxx.xx/assets/backend/css/cpanel_ifcs.css" type="text/css" media="screen, projection" />
    <!--[if lte IE 6]><link rel="stylesheet" href="http://xxxxx.xx/css/style_ie.css" type="text/css" media="screen, projection" /><![endif]-->
    
               
<link type="text/css" rel="stylesheet" href="http://xxxxx.xx/assets/image_crud/css/fineuploader.css" />
                    <link type="text/css" rel="stylesheet" href="http://xxxxx.xx/assets/image_crud/css/photogallery.css" />
                    <link type="text/css" rel="stylesheet" href="http://xxxxx.xx/assets/image_crud/css/colorbox.css" />
                
          


        
   
<link rel="stylesheet" type="text/css" href="http://xxxxx.xx/assets/bootstrap/css/bootstrap.min.css" media="screen" />
   
     
   
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
</head> 
<div class="container-fluid">
  <div class="row-fluid">
    <div class="span2">
           <div id="menu">
      <ul class="nav nav-list">
  <li class="nav-header">teoj.em@gmail.com</li>
  <li class=""><a href="http://xxxxx.xx/cpanel">Panel de Control</a></li>
  <li><a href="http://xxxxx.xx/cpanel/view_pages">Paginas</a></li>
  <li><a href="http://xxxxx.xx/cpanel/view_clientes">Clientes</a></li>
  <li><a href="http://xxxxx.xx/cpanel/view_inmuebles">Inmuebles</a></li>
  <li><a href="http://xxxxx.xx/cpanel/view_alquileres">Alquileres</a></li>
  <li><a href="http://xxxxx.xx/cpanel/view_contactos">Contactos</a></li>
  <li class="divider"></li>
  <li class=""><a href="http://xxxxx.xx/">Inicio</a></li>
  <li><a href="http://xxxxx.xx/auth/logout">Logout</a></li>
</ul>  
     
</div>


    </div>
    <div class="span10">
           


<script>
$(function(){
createUploader();
loadColorbox();
});
function loadColorbox()
{
$('.color-box').colorbox({
rel: 'color-box'
});
}
function loadPhotoGallery(){
$.ajax({
url: 'http://xxxxx.xx/cpanel/view_fotos/1/ajax_list',
cache: false,
dataType: 'text',
beforeSend: function()
{
$('.file-upload-messages-container:first').show();
$('.file-upload-message').html("Loading, please wait...");
},
complete: function()
{
$('.file-upload-messages-container').hide();
$('.file-upload-message').html('');
},
success: function(data){
$('#ajax-list').html(data);
loadColorbox();
}
});
}


function createUploader() {
var uploader = new qq.FineUploader({
element: document.getElementById('fine-uploader'),
request: {
endpoint: 'http://xxxxx.xx/cpanel/view_fotos/upload_file/1'
},
validation: {
allowedExtensions: ['jpeg', 'jpg', 'png', 'gif']
},
callbacks: {
onComplete: function(id, fileName, responseJSON) {
loadPhotoGallery();
}
},
debug: true,
/*template: '<div class="qq-uploader">' +
'<div class="qq-upload-drop-area"><span>Drop files here to upload</span></div>' +
'<div class="qq-upload-button">Upload files here</div>' +
'<ul class="qq-upload-list"></ul>' +
'</div>',
fileTemplate: '<li>' +
'<span class="qq-upload-file"></span>' +
'<span class="qq-upload-spinner"></span>' +
'<span class="qq-upload-size"></span>' +
'<a class="qq-upload-cancel" href="#">Cancel</a>' +
'<span class="qq-upload-failed-text">Failed</span>' +
'</li>',
*/

});
}


function saveTitle(data_id, data_title)
{
  $.ajax({
url: 'http://xxxxx.xx/cpanel/view_fotos/insert_title',
type: 'post',
data: {primary_key: data_id, value: data_title},
beforeSend: function()
{
$('.file-upload-messages-container:first').show();
$('.file-upload-message').html("Saving title...");
},
complete: function()
{
$('.file-upload-messages-container').hide();
$('.file-upload-message').html('');
}
});
}


window.onload = createUploader;


</script>
<!-- <div id="file-uploader-demo1" class="floatL upload-button-container"></div>
<div class="file-upload-messages-container hidden">
<div class="message-loading"></div>
<div class="file-upload-message"></div>
<div class="clear"></div>
</div>-->

<div id="fine-uploader"></div>
<div class="clear"></div>
<div id='ajax-list'>
</div>    </div>
  </div>
</div>




<script src="http://xxxxx.xx/assets/image_crud/js/jquery-1.8.2.min.js"></script>
    <script src="http://xxxxx.xx/assets/image_crud/js/jquery-ui-1.9.0.custom.min.js"></script>
    <script src="http://xxxxx.xx/assets/image_crud/js/fineuploader-3.2.min.js"></script>
    <script src="http://xxxxx.xx/assets/image_crud/js/jquery.colorbox-min.js"></script>
     
<script src="http://xxxxx.xx/assets/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>

 

All files exist and are well linked but when I load the page nothing appears, no upload button or any image. No envargo in the html code generated if everything appears.
Someone can guide me a little or I can say that tool know where the fault.
Thanks in advance

 


davidoster

davidoster
  • profile picture
  • Member

Posted 21 July 2013 - 10:48 AM

Hello [member=teoj].

You're missing from the view all the js files that are needed!

The js files need to exist on the head of the document.

Check again the original view that comes with Image CRUD,

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
<?php 
foreach($css_files as $file): ?>
	<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
	<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
<style type='text/css'>
body
{
	font-family: Arial;
	font-size: 14px;
}
a {
    color: blue;
    text-decoration: none;
    font-size: 14px;
}
a:hover
{
	text-decoration: underline;
}
</style>
</head>

teoj

teoj
  • profile picture
  • Member

Posted 21 July 2013 - 11:32 AM



 

Hello [member=teoj].

You're missing from the view all the js files that are needed!

The js files need to exist on the head of the document.

Check again the original view that comes with Image CRUD,

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
<?php 
foreach($css_files as $file): ?>
	<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
	<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
<style type='text/css'>
body
{
	font-family: Arial;
	font-size: 14px;
}
a {
    color: blue;
    text-decoration: none;
    font-size: 14px;
}
a:hover
{
	text-decoration: underline;
}
</style>
</head>

Hi davidoster.

The js and css files exist. js files is in the end and css files is in the head on the web. you can see it in the html generate.


davidoster

davidoster
  • profile picture
  • Member

Posted 21 July 2013 - 21:11 PM

js files need to be on the head.


teoj

teoj
  • profile picture
  • Member

Posted 22 July 2013 - 11:24 AM

Thanks davidoster were right, the js had to be in the head. I always put them down.
Now I have another problem that I'm still investigating, when I load an image in the input text for each image I get an error:
Message: Undefined property: stdClass :: $ title
Filename: views / list.php
But this error although I have not looked good. Thanks again.
 
 
Ok now all is working, my table dont has a column title.

Suresh Bhatol

Suresh Bhatol
  • profile picture
  • Member

Posted 24 July 2013 - 06:28 AM

function example4()
    {
        $image_crud = new image_CRUD();
 
        $image_crud->set_table('ws_example_4');
 
        $image_crud->set_primary_key_field('id');
        $image_crud->set_url_field('url');
        $image_crud->set_title_field('title');
        $target_path = 'assets/uploads/'; if(!is_dir($target_path)){mkdir($target_path);}
        $image_crud->set_ordering_field('priority')
        ->set_image_path($target_path);
 
        $output = $image_crud->render();
 
        $this->load->view("site-admin/index_crud", $output);
    }

Image upload not working.. i tired upload image but show Upload failed


davidoster

davidoster
  • profile picture
  • Member

Posted 24 July 2013 - 08:27 AM

Hello and welcome to the forums [member=suresh bhatol].

Check the permissions of the uploads directory to be 777.

 

Also this line if(!is_dir($target_path)){mkdir($target_path);}

might need the full path.


Suresh Bhatol

Suresh Bhatol
  • profile picture
  • Member

Posted 24 July 2013 - 13:32 PM

function example4()
    {
        $image_crud = new image_CRUD();
 
        $image_crud->set_table('ws_example_4');
 
        $image_crud->set_primary_key_field('id');
        $image_crud->set_url_field('url');
        $image_crud->set_title_field('title');
        $target_path = 'assets/uploads/'; if(!is_dir($target_path)){mkdir($target_path);}
        $image_crud->set_ordering_field('priority')
        ->set_image_path($target_path);
 
        $output = $image_crud->render();
 
        $this->load->view("site-admin/index_crud", $output);
    }

 

Image upload not working.. i tired upload image but show Upload failed