Recent Topics

1 Jan 12, 2008 00:58    

My b2evolution Version: 2.3.x

After searching the docs, the forums, and the 2.3.0 code, I cannot determine what code I need to get a list of post types from the database.

I've added 3 more types than the default "Post" and "Link" post types, and I want to list all 5 in my skin.

Any ideas on what php code I need?

(The plan eventually is to filter posts displayed by the post type)

Thanks,

Cindy Rae

2 Jan 12, 2008 01:03

Blog settings -> Post types -> New element

3 Jan 12, 2008 03:00

I need to know how to query the database for the existing post types (not create new post types from the back office)

4 Jan 12, 2008 03:29

For posts

SELECT *
FROM `evo_items__item` 
WHERE `post_ptyp_ID = 1`


for links

SELECT *
FROM `evo_items__item` 
WHERE `post_ptyp_ID = 2`

5 Jan 17, 2008 18:14

Actually, this is kinda what I wanted:

	function query_types()
	{
		global $DB;
	
		$this->ItemQuery->where_types( ' 1, 2, 5001, 5002, 5003 ' );
      
      $this->request = 'SELECT * FROM ' . $this->dbtable . $this->ItemQuery->get_where();      
      $this->result = $DB->get_results( $this->request, ARRAY_A );
      $this->result_num_rows = $DB->num_rows; 
      
      if ( isset( $GLOBALS[$this->id_param] ) )
      {
         $this->curr_type = $GLOBALS[$this->id_param];         
      }  
      else
      {
         $this->curr_type = 0;
      }    		
   }

Ideally, I wouldn't have to specify the types, but just query for all and screen out the "Reserved" types. However, that proved difficult based on the current core code.

- Cindy Rae

6 Jan 17, 2008 19:20

<?php
$sql = 'select ptyp_ID from T_items__type  where not( ptyp_name == \'Reserved\' )';
$all_types = $DB->get_results( $sql, ARRAY_A);
?>

¥

7 Jan 17, 2008 19:55

Update thanks to the blonde bimbo's reply:

	function query_types()
	{
		global $DB;
	    
      $this->request = "select * from " . $this->dbtable . " where not( " . $this->dbNameName . " = 'Reserved' ) AND not ( " . $this->dbNameName . " = 'Page' )";         

      $this->result = $DB->get_results( $this->request, ARRAY_A );
      $this->result_num_rows = $DB->num_rows; 
      
      if ( isset( $GLOBALS[$this->url_param_name] ) )
      {
         $this->curr_type = $GLOBALS[$this->url_param_name];         
      }  
      else
      {
         $this->curr_type = 0;
      }   
   }


Form is loading...