[eluser]ReyPM[/eluser]
Ok, I've found this amazing tool and trying to use in my development but I'm doing something wrong because don't work. See what I've done until now:
1. Load needed libraries in __construct() (The other libraries needed are autoloaded).
Code: public function __construct() {
parent::__construct();
$this->load->add_package_path(APPPATH . 'third_party/grocery_crud/');
$this->output->set_template('custom_cms');
$this->load->library('grocery_CRUD');
}
2. Write this piece of code in index():
Code: public function index() {
if ($this->my_usession->logged_in) {
$this->grocery_crud->set_table('trasegados')
->set_subject('Trasegados')
->columns('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
$this->grocery_crud->fields('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
$this->grocery_crud->required_fields('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
$this->grocery_crud->render();
$this->load->view('trasegados/form', $data);
} else {
redirect('user/login');
}
}
3. Echo $output at trasegados/form template:
Code: <?php $this->load->view('layout_login_header'); ?>
<?php echo $output ?>
<?php $this->load->view('layout_login_footer'); ?>
4. Add the needed code at layout_login_header:
Code: <?php foreach ($css as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
[removed]var base_url = '<?= base_url() ?>';[removed]
<?php foreach ($js as $file): ?>
[removed][removed]
<?php endforeach; ?>
But I got a lot of errors:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined variable: css
Filename: views/layout_login_header.php
Line Number: 11
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/layout_login_header.php
Line Number: 11
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: js
Filename: views/layout_login_header.php
Line Number: 15
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/layout_login_header.php
Line Number: 15
See the entire output image here http://www.dropmocks.com/mUTRR. Why this? What I'm doing wrong?
Cheers and thanks
[eluser]web-johnny[/eluser]
To your template you must write this :
Code: <?php $this->load->view('layout_login_header', array('css' => $css, 'js' => $js)); ?>
<?php echo $output ?>
<?php $this->load->view('layout_login_footer'); ?>
I think the wrong is only in the $this->load->view('layout_login_header'); . Hope this will solve your problem
[eluser]ReyPM[/eluser]
Nope  I changed as you suggest and still no working
[eluser]web-johnny[/eluser]
Ok I think I find it :-)
You will not use the view $this->load->view('trasegados/form', $data);
You have to this code to your template : (templates/frontend/custom-cms/template.php). So your template will be something like the template below: (the application/views/ is needed in the template, I still don't know why)
Code: <?php $this->load->view('application/views/layout_login_header', array('css' => $css, 'js' => $js)); ?>
<?php echo $output ?>
<?php $this->load->view('application/views/layout_login_footer'); ?>
delete you line $this->load->view('trasegados/form', $data); and if you want to add more views you can do it like this...
Code: function test()
{
$this->load->view(...); // for a view before the crud
$this->grocery_crud->....
$this->grocery_crud->render();
$this->load->view(...); // for a view after the crud
}
and your index function will be like this:
Code: public function index() {
if ($this->my_usession->logged_in) {
$this->grocery_crud->set_table('trasegados')
->set_subject('Trasegados')
->columns('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
$this->grocery_crud->fields('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
$this->grocery_crud->required_fields('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
$this->grocery_crud->render();
//$this->load->view('trasegados/form', $data);
} else {
redirect('user/login');
}
}
[eluser]ReyPM[/eluser]
Hmmm OK, this solve the problem but what about my layout? Now I'm only have the CRUD and I want, of course, the layout working togheter. Any way? Also I can see that you use Flexigrid  where I can change default settings? I don't want this to be collapsible
Cheers and thanks for your support
[eluser]web-johnny[/eluser]
[quote author="ReyPM" date="1303756369"]Hmmm OK, this solve the problem but what about my layout? Now I'm only have the CRUD and I want, of course, the layout working togheter. Any way? Also I can see that you use Flexigrid  where I can change default settings? I don't want this to be collapsible
Cheers and thanks for your support[/quote]
To your layout you can use your own template . For example in you layout_login_header you can have ( I just copy paste the home page of codeigniter ):
Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>CodeIgniter - Open source PHP web application framework</title>
<link rel="shortcut icon" href="/images/design/favicon.ico" type="image/x-icon" />
<link rel="home" href="http://codeigniter.com/" title="Home" />
<link rel="stylesheet" href="http://codeigniter.com/?css=global/styles.css.v.1296267222" type="text/css" media="screen, projection" charset="utf-8" />
<link rel="stylesheet" href="http://codeigniter.com/?css=global/sIFR-screen.css.v.1284169231" type="text/css" media="screen, projection" charset="utf-8" />
<link rel="stylesheet" href="http://codeigniter.com/?css=global/sIFR-print.css.v.1284169231" type="text/css" media="print" charset="utf-8" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta http-equiv='expires' content='-1' />
<meta http-equiv='pragma' content='no-cache' />
<meta name='robots' content='all' />
<meta name='description' content='CodeIgniter: an open source Web Application Framework that helps you write PHP programs' />
<meta name="keywords" content="EllisLab CodeIgniter PHP CMS Content Management System software framework " />
<!-- REQUIRED CODE goes here-->
<!-- END OF REQUIRED CODE-->
<!-- Reverse Links from EllisLab network sites -->
<link rev="expressionengine" href="http://expressionengine.com/"
title="The most flexible publishing system you'll ever meet" />
<link rev="pmachinepro" href="http://pmachinepro.com/"
title="Flexible and free blogging system that supports advanced features like multiple blogs, moblogging, and much more" />
<link rev="ellislab" href="http://ellislab.com/"
title="Where ideas hatch!" />
<link rev="enginehosting" href="http://enginehosting.com/"
title="High performance web hosting" />
<link rel="shortcut icon" href="/images/design/favicon.ico" type="image/x-icon" />
[removed][removed]
[removed]
var scene = {
src: '/images/sifr/scene.swf'
};
sIFR.delayCSS = true;
sIFR.activate(scene);
sIFR.replace({selector: 'h3' ,src: '/images/sifr/scene.swf' ,wmode:'transparent',css: { '.sIFR-root': { 'color': '#FF3C00' } } });
[removed]
<link rel="alternate" type="application/atom+xml" title="Master Atom feed" href="http://codeigniter.com/feeds/atom/full/" />
<link rel="alternate" type="application/rss+xml" title="Master RSS feed" href="http://codeigniter.com/feeds/rss/full/" />
</head>
<body id="home">
<div id="masthead">
<a href="http://ellislab.com/"><img src="/images/design/ellislab_network.gif" width="287" height="23" alt="Part of the EllisLab Network" /></a>
</div>
<div id="header">
<div id="login">
<a href="http://ellislab.com/forums/member/login/">Login</a> | <a href="http://ellislab.com/forums/member/register/">Register</a>
</div>
<h1><a href="/" title="CodeIgniter"><img src="/images/design/ci_logo2.gif" alt="CodeIgniter" width="170" height="73" /></a></h1>
</div>
<div id="siteNav">
<ul>
<li id="homenav"><a href="http://codeigniter.com/">Home</a></li>
<li id="downloadsnav"><a href="http://codeigniter.com/downloads/">Downloads</a></li>
<li id="newsnav"><a href="http://codeigniter.com/news/">News</a></li>
<li id="tutorialnav"><a href="http://codeigniter.com/tutorials/">VideoTutorials</a></li>
<li id="manualnav"><a href="http://ellislab.com/codeigniter/user-guide/">User Guide</a></li>
<li id="forumnav"><a href="http://ellislab.com/forums/">Forums</a></li>
<li id="wikinav"><a href="http://codeigniter.com/wiki/">Wiki</a></li>
<li id="bugnav"><a href="http://bitbucket.org/ellislab/codeigniter-reactor/issues?kind=bug">Bug Tracker</a></li>
</ul>
<div class="clear"></div>
</div>
<!-- Candy comes in a wrapper -->
<div id="wrapperWit">
[eluser]ReyPM[/eluser]
I have it but you don't understand me. See the image at: http://www.dropmocks.com/mUTRn. As you can see only the template related to CRUD appears so how I can maintain my layout and use CRUD at the same time. Understand now?
[eluser]web-johnny[/eluser]
The same thing you can do it for the footer for example :
Code: </div>.....
<div>Footer .....</div>....
</div>
</body>
</html>
I have created only two themes (flexigrid and datatables). If you want to create your own crud layout (like flexigrid) it needs work and I haven't documented the "Create your own theme" yet. But I think if you have your own cms template you will not have any problem with flexigrid or datatables.
[eluser]ReyPM[/eluser]
[quote author="web-johnny" date="1303756016"]You have to this code to your template : (templates/frontend/custom-cms/template.php).[/quote] Me again  I think I understand you now. I've see templates/custom_cms/template.php and found the the template code and need to change this in order to looks like my layout but what about with those controllers who don't use CRUD? How I call this template to maintain the same layout across the site navigation?
[eluser]web-johnny[/eluser]
We talk about the same thing . You can change the template and add your own . If you want post your template and you will understand , its really really easy. you can either have many templates . For example : $this->output->set_template('my_custom_cms_2'); I have a documentation for this if you click here. The custom-cms is just an example. You can write your own template for instance :
Code: <!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo $title; ?></title>
<meta charset="utf-8" />
<!-- Required Code -->
<?php foreach($css as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
[removed]var base_url = '<?=base_url()?>';[removed]
<?php foreach($js as $file): ?>
[removed][removed]
<?php endforeach; ?>
<!-- End of Required Code -->
<link type="text/css" rel="stylesheet" href="/templates/frontend/default/css/my_new_style.css" />
<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>
<div> Code divs and etc etc. You can even add views $this->load->view('application/views/header2.php') .... etc etc</div>
<div class='my-header'>
<a href='<?=site_url('>Offices</a> |
<a href='<?=site_url('>Employees</a> |
<a href='<?=site_url('>Customers</a> |
<a href='<?=site_url('>Orders</a> |
<a href='<?=site_url('>Products</a>
</div>
<div>Welcome George</div>
<div><?php
if(isset($modules->report))
foreach($modules->report as $module)
echo $module;
?></div>
<div style='height:20px;'></div>
<div>
<!-- Required Code -->
<?php echo $output; ?>
<!-- End of Required Code -->
</div>
<div> Code divs and etc etc</div>
</body>
</html>
|