Welcome Guest, Not a member yet? Register   Sign In
Tendoo CMS: Module Feature Improvements
#1

Hi, before submiting a RC for tendoo CMS, there was some improvements which was required to be done before.

As i said in one previous post "Help Us to decide", we was looking for a better ways to ease module assets management, since including those files within APPPATH is not allowed (we don't want to change CI core file and security measures).

After severals thoughts between codeigniter member and tendoo core developpers, we decided to include module assets within "public" folder at the root, and by the ways asset_helper has been improved to support this.

What's New ?

Some changes has been made so far, and all of them are not only about "modules" one especially was about frontend views (outside dashboard), handled by "load_frontend" hook with URI segments provided. So in details here a the new features :

- Modules can be extracted in zip file : for those who are working in a development environment (Available). This feature can be disabled from options (No yet implemented)

- "assets" is now a reserved folder name, since this folder will be moved to "FCPATH . 'public/modules/[module namespace]';

- "assets" is also included during extraction and saved to "assets" folder in the zip file.

- Asset_helper now supports one parameters : module namespace.

Especially for this last one, if you're working with a module "asset-ready", you can include for e.g css file like this.

PHP Code:
<?php
$jquery 
js_url'module_namespace' ) . 'jquery.js' // "module_namespace" is the one defined within config.xml
?>
<script src="<?php echo $jquery;?>">
</script> 

you can also use those functions in the same way : asset_url, css_url, swf_url, img_url, which points respectively to those folders.

- public/modules/[module_namespace]/
- public/modules/[module_namespace]/css
- public/modules/[module_namespace]/swf
- public/modules/[module_namespace]/images

The special case of "load_frontend" hook

As i told you earlier, "load_frontend" hook has been introduced and let you handle displays outside "dashboard". Here is how to use it (do you remember how to create a module ?)


PHP Code:
class cappuchino_frontend extends CI_model
{
    function 
__construct()
    {
        
parent::__construct();
        
$this->events->add_action'load_frontend' , array( $this 'frontend' ) ); // registering load_frontend hook.
        
$this->data        =    array();
    }
 
       
        
/**
         * This method handle URI segments and create an internal controller manager
        **/
 
       function frontend$params )

    {
        
// HOME
        
if( isset( $params[1] ) ){
            if( 
in_array$params[1] , array( 'home' 'restaurant' ) ) ){ // home and restaurant are now supported and available like this "http://exemple.com/index.php/home" and "http://exemple.com/index.php/restaurant"
                
$method    =    $params[1];
                
array_shift$params );
                
$this->$method    $params );
            }
        }
    }
}
new 
cappuchino_frontend

Now that we have an internal controller manager, we can now create those required methods (home and restaurant)

PHP Code:
// ... also within cappuchino_frontend class (see above)
 
       private function view$path $data = array() , $return false // internal views loader thanks to "Enrique Salavador" for his tips.
    
{
        return 
$this->load->view'../modules/cappuchino/views/' $path $data $return );
    }
    
// Home
    
function home()
    {
        if( 
riake'load_dependency' $_GET ) ){
                
            
$this->view'_header' );
            
$this->data'view' ]    =    $this->view'frontend-home' , array() , true );
            
$this->view'body' $this->data );
            
        } else {
            
            
$this->view'frontend-home' );
            
        }
    }
    function 
restaurant$page = array( 'home' ) )
    {
        if( 
riake$page ) == 'orders' ){
            
            if( 
riake$page ) == 'new' ){             // for new orders
            
                
if( riake'load_dependency' $_GET ) ){
                    
                    
$this->view'_header' );
                    
$this->data'view' ]    =    $this->view'restaurant-order-new' , array() , true );
                    
$this->view'body' $this->data );
                    
                } else {
                    
                    
$this->view'restaurant-order-new' );
                    
                }
                
            } else { 
// restaurant order list
                
                
if( riake'load_dependency' $_GET ) ){
                    
                    
$this->view'_header' );
                    
$this->data'view' ]    =    $this->view'restaurant-order-list' , array() , true );
                    
$this->view'body' $this->data );
                    
                } else {
                    
                    
$this->view'restaurant-order-list' );
                    
                }
                
            }
            
        } else {
            
            if( 
riake'load_dependency' $_GET ) ){
                
                
$this->view'_header' );
                
$this->data'view' ]    =    $this->view'restaurant-home' , array() , true );
                
$this->view'body' $this->data );
                
            } else {
                
                
$this->view'restaurant-home' );
                
            }
        } 
    } 

This process has been used within one developper module (Cappuchino), unfortunately it's a french extension but it's using jQuery mobile, and it's available like this "http://example.com/index.php/home". It's not yet complete, but you can download it if you want to test out "load_frontend" hook.

Image has been removed due to this forum limit file size.

Thanks for having read this.

Attached Files
.zip   cappuchino.zip (Size: 534.97 KB / Downloads: 71)
NexoPOS 2.6.2 available on CodeCanyon.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB