I am not sure if anyone has gotten back to you yet, but this is the  
process for creating post types and then displaying them, as far as I  
remember:

In your plugin you should have two methods, one that creates the post  
type upon activation, and then on that removes it when deactivating:

        function action_plugin_activation( $plugin_file ) {
                if( Plugins::id_from_file(__FILE__) ==  
Plugins::id_from_file($plugin_file) ) {
                        Post::add_new_type( 'my_post_type' );
                }
        }
        
        public function action_plugin_deactivation ( $file='' ) {
                
                if ( Plugins::id_from_file( $file ) ==  
Plugins::id_from_file( __FILE__ ) ) {                   
                        // deactivate our custom post type
                        Post::deactivate_post_type( 'my_post_type' );
                }
        }

Then you need to have a custom set of rewrite rules that tell habari  
when to show the new post type:

        public function filter_default_rewrite_rules( $rules ) {        
                $rules[] = array(
                        'name' => 'display_ my_post_type',
                        'parse_regex' => '%^ 
my_post_type(?:/page/(?P<page>[2-9]|[1-9] 
[0-9]+))?/?$%',
                        'build_str' => 'my_post_type/(page/{$page})',
                        'handler' => 'PluginHandler',
                        'action' => 'display_ my_post_type',
                        'priority' => 90,
                        'description' => 'Display my_post_type',
                );
                 return $rules;
        }
        
And finally you need to have a method to actually handle the display.  
Notice that the naming of this method matches the action in the rules  
array.

        public function action_plugin_act_display_ my_post_type($handler) {
                $paramarray = array();
                $paramarray['fallback'] = array(
                        'my_post_type.multiple',
                        'my_post_type.single',
                        'home',
                );
                
                // Makes sure home displays only entries
                $default_filters = array(
                        'content_type' => Post::type( 'my_post_type' ),
                );

                $paramarray['user_filters']= $default_filters;
                return $handler->theme->act_display( $paramarray );
        }

Finally in your my_post_type.multiple you would call the post loop  
like so:

        <?php foreach ( $posts as $post ) : ?>
                <?php $theme->content($post, 'home_posts'); ?>
        <?php endforeach; ?>

This is mostly from memory, so the syntax might not be exactly write,  
but I think it will give you a clear starting point.

On May 23, 2009, at 11:46 AM, Tomas Gonzalez Dowling wrote:

>
> Hi all,
>    I want to create a new post type, i inserted a new row in posttype
> table and after that i see at the admin that i can create that type of
> posts. But how I show that stuff from my theme?
>
> I'm using Habari 0.6.2.
> The main reason for doing this is to mantain a portfolio and manage  
> it easy.
>
> You can see my page at http://macshack.com.ar/habari-0.6.2
>
>
> Thanks in advance,
>
> -- 
>   (                  )
>   )\         )    ( /(       )
> (((_)  (    (     )\())(    (
> )\___  )\   )\  '(_))/ )\   )\  '
> ((/ __|((_)_((_)) | |_ ((_)_((_))
> | (__/ _ \ '  \()|  _/ _ \ '  \()
>  \___\___/_|_|_|  \__\___/_|_|_|
>    43  6F   6D     74  6F  6D
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/habari-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to