Welcome Guest, Not a member yet? Register   Sign In
Ionize - Free & Open Source creative CMS
#51

[eluser]Tottys Design[/eluser]
Hy, you might help me:

Here is the my problem:

I would like to load a model in the router class. How can I do?
Or make a connection with a database before loading a controller, and then load the controller that is given from the database query.

Please help me... Already 2 days working on.. Confused

-Editing or not the core files.
#52

[eluser]Michel-Ange[/eluser]
I'm sorry, but is your post Ionize related ? If not, please change your post thread.
#53

[eluser]Tottys Design[/eluser]
[quote author="Michel-Ange" date="1258518603"]I'm sorry, but is your post Ionize related ? If not, please change your post thread.[/quote]

I know that ionize has dynamic urls from database, as it is a CMS, and I thought that who made it, may help me with this, because are days im trying to do this... Confused If you can help me, please do it, I really appreciate
#54

[eluser]Michel-Ange[/eluser]
@Tottys Design : Loading a model in the Router class goes against the MVC principles of CI.

I had a look to your other post :
First, have a look at the MVC principles : In MVC, the controller "catch" all user entries, manage request / loads data through models and finaly feeds the view, which will be send to the user. The "router" can be see as a dispatcher which is here to understand the request and route to the good controller, nothing more.

A way to do what you want should be to create a main controller, which will load the model in charge of getting the controllers names from database. All other controllers will extends this main controller. With this way of thinking, you will keep the MVC logical without hacking the router lib.
Create a MY_Controller extending Controller in the librairies folder and then use inheritance for your other controllers.
#55

[eluser]Tottys Design[/eluser]
[quote author="Michel-Ange" date="1258554989"]@Tottys Design : Loading a model in the Router class goes against the MVC principles of CI.

I had a look to your other post :
First, have a look at the MVC principles : In MVC, the controller "catch" all user entries, manage request / loads data through models and finaly feeds the view, which will be send to the user. The "router" can be see as a dispatcher which is here to understand the request and route to the good controller, nothing more.

A way to do what you want should be to create a main controller, which will load the model in charge of getting the controllers names from database. All other controllers will extends this main controller. With this way of thinking, you will keep the MVC logical without hacking the router lib.
Create a MY_Controller extending Controller in the librairies folder and then use inheritance for your other controllers.[/quote]

So you are saying this:
MY_Controller extends Controller
Core_controller extends My_Controller
and when a request comes, Core_controller loads it and then, how can I load the other controllers the I would need, "gallery"..?
#56

[eluser]Unknown[/eluser]
I haven't seen the code yet but it looks very promising from the user perspective . anyway thank you for your efforts.
#57

[eluser]Michel-Ange[/eluser]
@Tottys Design : http://ellislab.com/forums/viewthread/135515/

@slashams : Thanks a lot for you positive feedback.
#58

[eluser]Kip zonder Kop[/eluser]
In the page controller I added the following code:
Code:
// Next article complete URL
         $article['next_url'] = '';
         $next = $this->article_model->get_adjacent_article($article,'next');
         if (isset($next['name']))
         {        
               $article['next_url'] = base_url() . Settings::get_lang() . '/' . $this->page['name'] . '/' . $next['name'];
         }
            
         // Previous article complete URL            
         $article['previous_url'] = '';
         $previous = $this->article_model->get_adjacent_article($article,'previous');
         if (isset($previous['name']))
         {        
               $article['previous_url'] = base_url() . Settings::get_lang() . '/' . $this->page['name'] . '/' . $previous['name'];
         }

In the article_model I added the following code:
Code:
function get_adjacent_article($current,$adjacent)
   {      
       if ($adjacent == 'previous')
       {
          $this->db->select_max('ordering');
          $this->db->where('ordering <', $current['ordering']);
       }
       else
       {
          $this->db->select_min('ordering');
          $this->db->where('ordering >', $current['ordering']);
       }
      
       $this->db->select('name');
       $this->db->where('online', '1');    
       $this->db->where('id_page', $current['id_page']);
       $this->db->where('((publish_off > ', 'now()', false);
       $this->db->or_where('publish_off = ', '0)' , false);  
       $this->db->where('(publish_on < ', 'now()', false);
       $this->db->or_where('publish_on = ', '0))' , false);
        
       $query = $this->db->get($this->table);
       if ($query->num_rows() > 0)
       {
         return $query->row_array();
       }
       return $false;              
   }

Now in my article templates I can use 2 additional tags:

Code:
<ion:previous_url />
<ion:next_url />

to create url's pointing to the next and previous published article.
I'd like to have something like this to the system to enable easier navigation from one article to the other. Tell me what you think.
#59

[eluser]Michel-Ange[/eluser]
@Kip zonder Kop : Great add !

Just one comment :
In the article_model, you don't need to write all the publish filter code yourself.
This will be is enough :

Code:
function get_adjacent_article($current,$adjacent)
{  
       if ($adjacent == 'previous')
       {
          $this->db->select_max('ordering');
          $this->db->where('ordering <', $current['ordering']);
       }
       else
       {
          $this->db->select_min('ordering');
          $this->db->where('ordering >', $current['ordering']);
       }
      
       $this->db->select('name');
       $this->db->where('id_page', $current['id_page']);

       // The publish filter
    if ( $this->publish_filter === true )
        $this->filter_on_published();
    
       $query = $this->db->get($this->table);
       if ($query->num_rows() > 0)
       {
         return $query->row_array();
       }
       return $false;              
}
#60

[eluser]Michel-Ange[/eluser]
@BlueRabbit : To use only one language and remove the lang part of the URL :

In the page controller (application/controllers/page.php), in the function get_navigation(), add :

Code:
/*
         * FTL render
         *
         */
        if (!empty($pages))
        {
            $data = array(
                'items' => array_values($pages),
// Modified code
                'base_url' => base_url(),
                'lang_url' => base_url().Settings::get_lang().'/',
// End of Modified code
                'navigation' => array($this, 'get_meta_keywords')
            );
            
            return $this->render_callback($view, $data);
        }

This will give you the choice, in the navigation view, to use <ion:base_url /> or <ion:lang_url /> which contains the lang code URL part.

This modification will be available in the 0.91 version, as the Brian modifications.

Sorry to be a little bit slow, but after my daily work, I'm currently working on a big project.




Theme © iAndrew 2016 - Forum software by © MyBB