⚠ 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

output not displaying correctly



ridders24
  • profile picture
  • Member

Posted 18 March 2012 - 10:00 AM

Hi,

Just installed Grocery CRUD, and currently following the tutorial "http://www.grocerycrud.com/documentation/create-crud-codeigniter-tutorial", however I appear to be having an issue with the output. I have gone through the whole tutorial, and appears that the issue is with the controller not passing the output to the view. So I have gone back to stage 5 to make sure the output is similar to what is suggested and this is what I get, which I don't see any problem with:


[size=2]stdClass Object
(
[output] =>[/size]


[size=2]Add Record
Title

Body

Actions
test post

testing post entry.

second test post

test 1234

test

lalalalala

Search:
Page of 1
Displaying 1 to 3 of 3 items[/size]

[size=2] [js_files] => Array
(
[6b63be097451dbb96a950604e9a72faddca0131a] => http://localhost/ci/assets/grocery_crud/js/jquery-1.7.1.min.js
[2d2b031fb606852768dc4c9a3c457545558cc924] => http://localhost/ci/assets/grocery_crud/themes/flexigrid/js/cookies.js
[6629a324ade6d489aff77292cb02e31d9188a6bb] => http://localhost/ci/assets/grocery_crud/themes/flexigrid/js/flexigrid.js
[f32759f44ae94dad1a17f0b37a77f4085f415e18] => http://localhost/ci/assets/grocery_crud/themes/flexigrid/js/jquery.form.js
[0e49c025c7181e38222132fd81db98f418071bf4] => http://localhost/ci/assets/grocery_crud/themes/flexigrid/js/jquery.numeric.js
)[/size]
[size=2] [css_files] => Array
(
[f1731e27afe02ab899b16daf8ae4a5ac8ac05d4e] => http://localhost/ci/assets/grocery_crud/themes/flexigrid/css/flexigrid.css
)[/size]
[size=2])[/size]


This is the code for my controller:


[size=2]<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test extends CI_Controller {

function __construct()
{
parent::__construct();

/* Standard Libraries of codeigniter are required */
$this->load->database();
$this->load->helper('url');
/* ------------------ */

$this->load->library('grocery_CRUD');

}

public function index()
{
echo "<h1>Welcome to the world of Codeigniter</h1>";//Just an example to ensure that we get into the function
die();
}

public function entries()
{
$this->grocery_crud->set_table('entries');
$output = $this->grocery_crud->render();

$this->_example_output($output);
}

function _example_output($output = null)

{
$this->load->view('test_view.php',$output);
}
}

/* End of file main.php */
/* Location: ./application/controllers/main.php */[/size]



And this is the code for my view:


[size=2]<!DOCTYPE html>
<html lang="en">
<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>
<body>
<!-- Beginning header -->
<div>
<a href='<?php echo site_url('examples/offices_management')?>'>Offices</a> |
<a href='<?php echo site_url('examples/employees_management')?>'>Employees</a> |
<a href='<?php echo site_url('examples/customers_management')?>'>Customers</a> |
<a href='<?php echo site_url('examples/orders_management')?>'>Orders</a> |
<a href='<?php echo site_url('examples/products_management')?>'>Products</a> |
<a href='<?php echo site_url('examples/film_management')?>'>Films</a>

</div>
<!-- End of header-->
<div style='height:20px;'></div>
<div>
<?php echo $output; ?>

</div>
<!-- Beginning footer -->
<div>Footer</div>
<!-- End of Footer -->
</body>
</html>[/size]




What I don't understand is why the post entries in the table do not get displayed on http://localhost/test but only in the http://localhost/test/entries. Any help with this would be great.

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 18 March 2012 - 13:13 PM

Yes this is a known issue of the grocery CRUD ( http://www.grocerycrud.com/documentation/known-issues ). As I have a solution for this just don't use the library to the index. In general grocery CRUD has lot of scenarios to deal with the url thing and is still a big change to fix the issue of the index too. For now you can just have it in a different function that index for example entries or whatever you like without any problem.

ridders24
  • profile picture
  • Member

Posted 18 March 2012 - 15:36 PM

Thanks for your reply.