You are not logged in.
Dear all,
I'm new to codeigniter and so far find it extremely usefull for creating web apps. I have created several controllers, models and views in codeigniter but came at a point where a cms was needed in order to create a three level administration menu.
Ionize CMS is perfect for what I need but I have a basic (rookie) question : How do I migate the controllers, the models and the views that I created on Codeigniter to Ionize installation ? Is a simple copy paste from CI to Ionize enough ?
...
Offline
Check the demo modules
<ion:ukyo from="Turkey" />
User's documentation | Webdesigner's doc | Language files | My Github Repositories
Please send your first message to a forum section, not forum users or administration.
Offline
Thanks for your prompt reply ukyo !
I've managed to create new modules following the Demo module and the "http://ionizecms.com/en/news/ionize-creating-a-module" howto guide.
Another question: Do I need to define all my custom db tables to the "config.xml" of the newly created module?
The next step is to load the custom modules to my existing theme.
...
Offline
If you define all your custom db tables to "config.xml" next module installation will be easy for you
<ion:ukyo from="Turkey" />
User's documentation | Webdesigner's doc | Language files | My Github Repositories
Please send your first message to a forum section, not forum users or administration.
Offline
Thanks again ukyo! I see the importance of defining the custom db tables.
What I still haven't found is how to link the modules, that I've created, to a page inside my theme. I.e.I have created a Module (Name: "Photo_albums Module", URI: "photo_albums") and would like to display the content inside my ionize theme's page. Is that possible ?
...
Offline
You need to write also tags for your module. And you can create a page "Photo Album" and special view for "Photo Album" page you can use tags inside your view file like :
<ion:photo_album>
<ion:title />
</ion:photo_album><ion:ukyo from="Turkey" />
User's documentation | Webdesigner's doc | Language files | My Github Repositories
Please send your first message to a forum section, not forum users or administration.
Offline
Thanks again for the guidance ukyo. I've managed to create the tag functions on tags.php file of my module (I renamed it to Photoalbums). I followed the example of "Fancyupload" module.
Inside tags.php :
public static function index(FTL_Binding $tag)
{
// Get the module URI
include APPPATH . 'config/modules.php';
$uri = array_search('Photoalbums', $modules);
$tag->expand();
return $tag->parse_as_nested(file_get_contents(MODPATH.'Photoalbums/views/photoalbums/create'.EXT));
} The problem is that i want to pass a variable from the controller to the"create" view (i.e. $private_code_element). How can I do it ?
On plain CodeIgniter I was using it as follows:
controller
$data_to_view['private_code_element'] = $private_code;
$this->load->view('photoalbums/create',$data_to_view); ...
Offline
In Ionize, you don't directly pass a variable to the view. Instead, you use the <ion:... /> tags. Since you've already created your tags library, here's what you should do:
1. Assuming you've already created your $private_code, add that to your $tag variable locals in your index function before expanding the tag:
...
$tag->locals->private_code = $private_code;
$tag_expand();
...2. Create a function to return your private code to your view:
public static function private_code(FTL_Binding $tag) {
return isset($tag->locals->private_code) ? $tag->locals->private_code : '';
}3. Include the tag in your view:
<ion:photo_album>
<p>My private code is <ion:private_code />!</p>
<ion:title />
</ion:photo_album>Offline
Its possible to use also directly pass a variable. but its making ionize slow.
<ion:ukyo from="Turkey" />
User's documentation | Webdesigner's doc | Language files | My Github Repositories
Please send your first message to a forum section, not forum users or administration.
Offline
Thanks a lot kojiroh and ukyo! That worked for me! I also realized that is much better to move the code from the controller to the tags library. Is that approach correct?
Furthermore, I would like to ask if I can call the helper functions inside the tags i.e.:
$ci = &get_instance();
$ci->load->helper('form');
$ci->load->library('form_validation');And after the above, to actually perform the validations:
$ci->form_validation->set_rules('album_name', 'Album Name', 'required');
$ci->form_validation->set_rules('description', 'Album Description', 'required');
$ci->form_validation->set_rules('privacy', 'privacy', 'required');
$ci->form_validation->set_rules('private_code', 'Private Code', 'required');Is it possible and and good in terms of design ?
...
Offline
Check the simpleform module for form validation an other things will help you
<ion:ukyo from="Turkey" />
User's documentation | Webdesigner's doc | Language files | My Github Repositories
Please send your first message to a forum section, not forum users or administration.
Offline
Thanks for the tips! After configuring the "Simpleform" module, I've managed create the form that I wanted and write the required data to the database.
My problem now is that I don't know how to pass an object (or an array) to the tag.
I.e.
1. Inside my users tag I define an object called $output which consists of two arrays.
public function users(FTL_Binding $tag)
{
....
$output = $ci->my_crud->render();
$tag->locals->output_tag = $output;
$tag->expand();
}2.I define the output_tag which should return the $output object
public static function output_tag(FTL_Binding $tag) {
return isset($tag->locals->output_tag) ? $tag->locals->output_tag : '';
}3. I call the output_tag inside my view :
<ion:users>
<ion:output_tag/>
</ion:users>I get the following error :
A PHP Error was encountered
Severity: 4096
Message: Object of class stdClass could not be converted to string
Filename: ftl/parser.php
Line Number: 159
Can you help me pass the object in the view via tag ?
...
Offline
It is possible that Ionize needs arrays to work with tags so you might want to convert your DB objects to arrays via row_array or result_array.
Edit: Disregard the above, I totally missed the point.
You can't directly pass an object or an array to the view using tags. What you have to do is define more nested tags. For example, if you have an array called "car" with two keys, "color" and "year", you would have to create 3 tags: car, car_color and car_year. The first one should set a local variable for your car and expand the tag; while the other ones should return the corresponding keys of the local car variable. I can't write a code example right now but I hope this much can help you.
Last edited by kojiroh (2012-04-24 23:20:54)
Offline
Quick way to get data from array to tag :
/**
* @usage <ion:users>
* <ion:user field="your_field_name" />
* </ion:users>
*/
public static function user(FTL_Binding $tag) {
$field = (isset($tag->attr['field']) ) ? $tag->attr['field'] : FALSE;
if ($field) {
if (!empty($tag->locals->user[$field]))
return self::wrap($tag, $tag->locals->user[$field]);
}
return '';
}<ion:ukyo from="Turkey" />
User's documentation | Webdesigner's doc | Language files | My Github Repositories
Please send your first message to a forum section, not forum users or administration.
Offline
I also got a new idea while thinking over this: you serialize your object or array and return that value, and then unserialize it on your view. It's not a very nice approach and I'm not sure if it'll work, but it just might.
Last edited by kojiroh (2012-04-25 17:40:01)
Offline
© 2010-2012 Partikule | Web agency Paris, France