⚠ 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

Table display problem



BrainMill

BrainMill
  • profile picture
  • Member

Posted 15 January 2013 - 08:30 AM

This is my controller


<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Users extends CI_Controller {
public function index()
{
is_logged_in();
$this->load->helper(array('form', 'url'));
$data['title'] = "Manage users";
$this->load->view('templates/header', $data);
$this->load->view('menu');
$this->grocery();
$this->load->view('templates/footer');
}
private function grocery() {
$this->load->library('grocery_CRUD');
$this->grocery_crud->set_table('users');
$output = $this->grocery_crud->render();
$this->table_output($output);

}
function table_output($output = null) {
$this->load->view('users/users',$output);
}
}



When i load the "Users" page It's displayed like this

The site is hosted in /var/www folder

Here are my config files:

/var/www/.htaccess

<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>



application/config/config.php

$config['base_url'] = '';
$config['index_page'] = '';


apache site configuration

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>



Please can you help me to understand where is my fault?

victor

victor
  • profile picture
  • Member

Posted 15 January 2013 - 13:46 PM

you should change the base url.

victor

victor
  • profile picture
  • Member

Posted 15 January 2013 - 13:54 PM

if you don't set the base url your base url is a query string. for example: localhost/your-controller/your-method/your-param/.
but in this case browser doesn't load the Javascript and css files.

BrainMill

BrainMill
  • profile picture
  • Member

Posted 15 January 2013 - 15:31 PM

I use .htaccess to avoid the display of index.php in every url. Before using .htaccess i tried with index.php as a base url but the problem remained the same

victor

victor
  • profile picture
  • Member

Posted 15 January 2013 - 16:23 PM

have look at path to the js and css files after rendering and type it here. I'm sure problem is in the base_url. the library use base_url. You need change the base url. for example http://your-site.com and then it will work fine. You use the .htaccess file to remove index.php from your url. But it is not base url.

BrainMill

BrainMill
  • profile picture
  • Member

Posted 17 January 2013 - 11:25 AM

I added the base url path like "https://172.16.4.1/" but the problem remains the same

I also tried to insert a record into my hosts file like

172.16.4.1 something.net

and to access to the site using the hostname instead of ip address. I also changed the url path accordingly but the table display problem continues


At the top of the html code in the rendered page there are this lines


var base_url = 'http://172.16.4.1/';
var subject = 'Record';
var ajax_list_info_url = 'http://172.16.4.1/users/index/ajax_list_info';
var unique_hash = '068dca7bc4ee03b2701306b7d8761cec';


In the same code at bottom are this lines


<script type="text/javascript">
var default_javascript_path = 'http://172.16.4.1/assets/grocery_crud/js';
var default_css_path = 'http://172.16.4.1/assets/grocery_crud/css';
var default_texteditor_path = 'http://172.16.4.1/assets/grocery_crud/texteditor';
var default_theme_path = 'http://172.16.4.1/assets/grocery_crud/themes';
var base_url = 'http://172.16.4.1/';
</script>


It looks like it cannot load something from assets folder

I also tried disabling .htaccess usage and reverting to the display of index.php line in the url and the problem is still here :-(

victor

victor
  • profile picture
  • Member

Posted 17 January 2013 - 11:52 AM

As I see you forgot to copy code from the example which includes all scripts and css files in the head. show your view file. I think the problem is here.

victor

victor
  • profile picture
  • Member

Posted 17 January 2013 - 12:08 PM

show the head from your html.

BrainMill

BrainMill
  • profile picture
  • Member

Posted 17 January 2013 - 12:27 PM

Sorry, here it is


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Manage users</title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>



Here the code of the template view file that generates it

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?php if(! is_null($title)) echo $title; ?></title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>

victor

victor
  • profile picture
  • Member

Posted 17 January 2013 - 13:20 PM

take a look at header from the example. Copy and paste that code. I type it from phone and I can't type for you that code.

victor

victor
  • profile picture
  • Member

Posted 17 January 2013 - 13:25 PM

if you don't understand how to make it I can type message to you tonight.

BrainMill

BrainMill
  • profile picture
  • Member

Posted 17 January 2013 - 14:49 PM

Ok!!! I've made it! Thank you very much for your help!

I read the examples.php and example.php and I understood everything.

Wrongly I was following this page http://www.grocerycrud.com/documentation/create-crud-codeigniter-tutorial

Here is the correct code:


function index()
{
$this->load->helper('url');
$this->load->library('grocery_CRUD');
$this->grocery_crud->set_table('users');
$this->grocery((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
}

function grocery($output = null) {
$output = $this->grocery_crud->render();
$this->load->view('templates/header', $output);
$this->load->view('menu');
$this->load->view('users/users',$output);
$this->load->view('templates/footer');
}



It needs a lot of expansions but at least it works :-)

victor

victor
  • profile picture
  • Member

Posted 17 January 2013 - 19:33 PM

you can make it easier :)
what is " $this->grocery"?
paste this code in your header:


<?php
if($crud['css_files']):foreach($crud['css_files'] as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; endif;?>
<?php
if($crud['js_files']): foreach($crud['js_files'] as $file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; endif;?>