Recent Topics

1 Mar 15, 2004 19:10    

this hack does NOT work with b2evo 0.9.x

ok, this hack will give you 3 new fields for every entry. one is used for current mood and the others can be used as you like.

the original hack is this one http://www.lossofsignal.net/index.php?p=19 for wordpress. so most of the credits goes to x3kep

!!! THIS HACK MODIFIES A LOT OF FILES IN A HEAVY WAY, SO BACKUP YOUR FILES FIRST!!!

i use big parts of the code, to make it easier for you to find the right part.

first of all you need to alter the evo_posts table. if haven't changed tablenames, you can use the following SQL


ALTER TABLE `evo_posts` ADD `post_mood` SMALLINT( 6 ) DEFAULT '0' NOT NULL ,
ADD `post_customfield1` TINYTEXT NOT NULL ,
ADD `post_customfield2` TINYTEXT NOT NULL ;

next open b2evocore/_functions.php, go to the very bottom and right above the closing


?>

insert this


// begin custom fields + mood hack

function displayMoodList($curmood) {
         //get list of moods
         //give full url to mood list file
         global $baseurl;

         $AllMoods = file($baseurl.'/moodlist.txt');
          sort($AllMoods);
          foreach($AllMoods as $line_num => $AMood) {
   		 $data = explode(":",$AMood);
                 if (number_format($curmood) == number_format($data[1])) {
                     echo "<option SELECTED value='" .$data[1] ."'>" .$data[0] ."\n";
                 }else {
                     echo ("<option value='") .$data[1] ."'>" .$data[0] ."\n";
                 }         
  	  }
 
}

function displayMood($num) {
         //finds the mood $num is and echo's the 
         //associated html code for the mood and image
	 global $baseurl;
	 
         $AllMoods = file($baseurl.'/inc/moodlist.txt');
         foreach($AllMoods as $line_num=>$AMood) {
	 $data = explode(":",$AMood);
	// echo "$data[1] = $num" ;
             if (number_format($data[1]) == number_format($num)) {
                   // echo $data[0] ."&<img src=\"mood/" .strtolower($data[0]) .".gif\" alt=\"(" .$data[0] .")\">";
                   return $data[0];
                  break; //find first entry only and quit
		}
         }
}

// end custom fields + mood hack

now open b2evocore/_functions_bposts.php
there you have to do some modifications:

change


function bpost_create( 
	$author_user_ID, 							// Author
	$post_title,
	$post_content,
	$post_timestamp,
	$main_cat_ID = 1,									// Main cat ID
	$extra_cat_IDs = array(),			// Table of extra cats
	$post_status = 'published',
	$post_lang = 'en',
	$post_trackbacks = '',
	$autobr = 0,									// No AutoBR has been used by default
	$pingsdone = true,
	$post_url = '' )

to


function bpost_create( 
	$author_user_ID, 							// Author
	$post_title,
	$post_content,
	$post_timestamp,
	$main_cat_ID = 1,									// Main cat ID
	$extra_cat_IDs = array(),			// Table of extra cats
	$post_status = 'published',
	$post_lang = 'en',
	$post_trackbacks = '',
	$autobr = 0,									// No AutoBR has been used by default
	$pingsdone = true,
// begin custom fields and mood hack
	$post_url = '',

	$post_currentmood = 0,
	$post_customfield1 = '',
	$post_customfield2 = '' )
// end custom fields and mood hack

in the same function, add this


// begin custom fields and mood hack

	$query = "INSERT INTO $tableposts( post_author, post_title, post_content, post_date, post_category,  post_status, post_lang, post_trackbacks, post_autobr, post_flags, post_wordcount, post_mood, post_customfield1, post_customfield2 ) ";
	$query .= "VALUES( $author_user_ID, '".addslashes($post_title)."', '".addslashes($post_content)."',	'$post_timestamp', $main_cat_ID,  '$post_status', '$post_lang', '".addslashes($post_url)."', $autobr, '".implode(',',$post_flags)."', ".bpost_count_words($post_content).", $post_currentmood, '$post_customfield1', '$post_customfield2' )";
	
// end custom fields and mood hack

right above


// TODO: START TRANSACTION

then change


function bpost_update( 
	$post_ID,
	$post_title,
	$post_content,
	$post_timestamp = '',
	$main_cat_ID = 1,							// Main cat ID
	$extra_cat_IDs = array(),			// Table of extra cats
	$post_status = 'published',
	$post_lang = 'en',
	$post_trackbacks = '',
	$autobr = 0,									// No AutoBR has been used by default
	$pingsdone = true,
	$post_url = '' )

to


function bpost_update( 
	$post_ID,
	$post_title,
	$post_content,
	$post_timestamp = '',
	$main_cat_ID = 1,							// Main cat ID
	$extra_cat_IDs = array(),			// Table of extra cats
	$post_status = 'published',
	$post_lang = 'en',
	$post_trackbacks = '',
	$autobr = 0,									// No AutoBR has been used by default
	$pingsdone = true,
// begin custom fields and mood hack

	$post_url = '',
	
	$post_currentmood = 0,
	$post_customfield1 = '',
	$post_customfield2 = '' )
	
// end custom fields and mood hack

in the same function add


// begin custom field and mood hack
	$query .= "post_wordcount = '".bpost_count_words($post_content)."', ";
	$query .= "post_mood = $post_currentmood, ";
	$query .= "post_customfield1 = '$post_customfield1', ";
	$query .= "post_customfield2 = '$post_customfield2' ";
// end custom field and mood hack

right above this


	$query .= "WHERE ID = $post_ID";
	// echo $query;
	$querycount++;
	$result = mysql_query($query);
	if( !$result ) return 0;

change this


function get_postdata($postid) 
{
	global $postdata, $tableusers, $tablesettings, $tablecategories, $tableposts, $tablecomments, $querycount, $show_statuses;

	if( !empty($postdata) && $postdata['ID'] == $postid )
	{	// We are asking for postdata of current post in memory! (we're in the b2 loop)
		// Already in memory! This will be the case when generating permalink at display
		// (but not when sending trackbacks!)
		// echo "*** Accessing post data in memory! ***<br />\n";
		return($postdata);
	}

	// echo "*** Loading post data! ***<br>\n";
	// We have to load the post
	$sql = "SELECT ID, post_author, post_date, post_status, post_lang, post_content, post_title, post_trackbacks, post_category, post_autobr, post_flags, post_wordcount, cat_blog_ID FROM $tableposts INNER JOIN $tablecategories ON post_category = cat_ID WHERE ID = $postid";
	// Restrict to the statuses we want to show:
	// echo $show_statuses;
	$sql .= ' AND '.statuses_where_clause( $show_statuses );

	//echo $sql;

to


function get_postdata($postid) 
{
	global $postdata, $tableusers, $tablesettings, $tablecategories, $tableposts, $tablecomments, $querycount, $show_statuses;

	if( !empty($postdata) && $postdata['ID'] == $postid )
	{	// We are asking for postdata of current post in memory! (we're in the b2 loop)
		// Already in memory! This will be the case when generating permalink at display
		// (but not when sending trackbacks!)
		// echo "*** Accessing post data in memory! ***<br />\n";
		return($postdata);
	}

	// echo "*** Loading post data! ***<br>\n";
	// We have to load the post
// begin custom field and mood hack
	$sql = "SELECT ID, post_author, post_date, post_status, post_lang, post_content, post_title, post_trackbacks, post_category, post_autobr, post_flags, post_wordcount, cat_blog_ID, post_mood, post_customfield1, post_customfield2 FROM $tableposts INNER JOIN $tablecategories ON post_category = cat_ID WHERE ID = $postid";
// end custom field and mood hack
	// Restrict to the statuses we want to show:
	// echo $show_statuses;
	$sql .= ' AND '.statuses_where_clause( $show_statuses );

	//echo $sql;

in the same function add


// begin custom field + mood hack
			'currentmood' => $myrow->post_mood,
			'customfield1' => $myrow->post_customfield1,
			'customfield2' => $myrow->post_customfield2,
// end custom field + mood hack

bellow


			'Flags' => explode( ',', $myrow->post_flags ),
			'Wordcount' => $myrow->post_wordcount,
			'Blog' => $myrow->cat_blog_ID,

at the very bottom of the file add



function display_currentmood ($before = '', $after = '') {
	global $postdata; 
	
	$currentmood = $postdata['currentmood'];

	if ($currentmood != 0) { 
		echo format_to_output( $before.displayMood($currentmood).$after, 'htmlbody' );  
	}
	
	return;
	
}

function display_customfield1 ($before = '', $after = '') {
	global $postdata; 
	
	$customfield1 = $postdata['customfield1'];

	if ($customfield1 != '') { 
		echo format_to_output( $before.$customfield1.$after, 'htmlbody' );  
	}
	
	return;
	
}

function display_customfield2 ($before = '', $after = '') {
	global $postdata; 
	
	$customfield2 = $postdata['customfield2'];

	if ($customfield2 != '') {
		echo format_to_output( $before.$customfield2.$after, 'htmlbody' );  
	}
	
	return;
	
}

right above the closing


?>

the next file is
b2evocore/_class_itemlist.php

change


		$this->request = "SELECT DISTINCT ID, post_author, post_date, post_status, post_lang, post_content, post_title, post_trackbacks, post_category, post_autobr, post_flags, post_wordcount, post_karma ";

to


//begin custom field and mood hack
	
		$this->request = "SELECT DISTINCT ID, post_author, post_date, post_status, post_lang, post_content, post_title, post_trackbacks, post_category, post_autobr, post_flags, post_wordcount, post_karma, post_mood, post_customfield1, post_customfield2 ";

//end custom field and mood hack

change this


	function get_postdata() 
	{
		global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages;
		global $pagenow;

		if(!$this->preview) 
		{	// This is not preview:
			//	echo 'REAL POST';
			$row = & $this->row;
			$id = $row->ID;
			// echo 'starting ',$row->post_title;
			$postdata = array (
				'ID' => $row->ID, 
				'Author_ID' => $row->post_author,
				'Date' => $row->post_date,
				'Status' => $row->post_status, 
				'Lang' =>  $row->post_lang, 
				'Content' => $row->post_content,
				'Title' => $row->post_title,
				'Url' => $row->post_trackbacks,
				'Category' => $row->post_category,
				'AutoBR' => $row->post_autobr, 
				'Flags' => explode( ',', $row->post_flags ),
				'Wordcount' => $row->post_wordcount,
				'Karma' => $row->post_karma // this isn't used yet 
				);
		} 
		else
		{	// We are in preview mode!
			//	echo 'PREVIEW';
			// we need globals for the param function
			global $preview_userid, $preview_date, $post_status, $post_lang, $content, $post_title, $post_url, $post_category, $post_autobr, $edit_date, $aa, $mm, $jj, $hh, $mn, $ss, $user_level, $localtimenow;
	
			$id = 0;
			param( 'preview_userid', 'integer', true );
			param( 'post_status', 'string', true );
			param( 'post_lang', 'string', true );
			param( 'content', 'html', true );
			param( 'post_title', 'html', true );
			param( 'post_url', 'string', true );
			param( 'post_category', 'integer', true );
			param( 'post_autobr', 'integer', 0 );
	
			$post_title = format_to_post( $post_title, 0 ); 

to


	function get_postdata() 
	{
		global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages;
		global $pagenow;

		if(!$this->preview) 
		{	// This is not preview:
			//	echo 'REAL POST';
			$row = & $this->row;
			$id = $row->ID;
			// echo 'starting ',$row->post_title;
			$postdata = array (
				'ID' => $row->ID, 
				'Author_ID' => $row->post_author,
				'Date' => $row->post_date,
				'Status' => $row->post_status, 
				'Lang' =>  $row->post_lang, 
				'Content' => $row->post_content,
				'Title' => $row->post_title,
				'Url' => $row->post_trackbacks,
				'Category' => $row->post_category,
				'AutoBR' => $row->post_autobr, 
				'Flags' => explode( ',', $row->post_flags ),
				'Wordcount' => $row->post_wordcount,
//begin custom field and mood hack
				'Karma' => $row->post_karma, // this isn't used yet 
				'currentmood' => $row->post_mood,
				'customfield1' => $row->post_customfield1,
				'customfield2' => $row->post_customfield2
//end custom field and mood hack
				);
		} 
		else
		{	// We are in preview mode!
			//	echo 'PREVIEW';
			// we need globals for the param function
//begin custom field and mood hack
			global $preview_userid, $preview_date, $post_status, $post_lang, $content, $post_title, $post_url, $post_category, $post_customfield1, $post_customfield2, $post_mood, $post_autobr, $edit_date, $aa, $mm, $jj, $hh, $mn, $ss, $user_level, $localtimenow;
	
//end custom field and mood hack
			$id = 0;
			param( 'preview_userid', 'integer', true );
			param( 'post_status', 'string', true );
			param( 'post_lang', 'string', true );
			param( 'content', 'html', true );
			param( 'post_title', 'html', true );
			param( 'post_url', 'string', true );
			param( 'post_category', 'integer', true );
			param( 'post_autobr', 'integer', 0 );
//begin custom field and mood hack

			param( 'post_customfield1', 'string' );
			param( 'post_customfield2', 'string' );
			param( 'post_mood', integer, 0 );
//end custom field and mood hack
	
			$post_title = format_to_post( $post_title, 0 ); 

and in the same function change this


			$postdata = array (
				'ID' => 0, 
				'Author_ID' => $preview_userid,
				'Date' => $post_date,
				'Status' => $post_status,
				'Lang' =>  $post_lang,
				'Content' => $content,
				'Title' => $post_title,
				'Url' => $post_url,
				'Category' => $post_category,
				'AutoBR' => $post_autobr,
				'Flags' => array(),
				'Wordcount' => bpost_count_words( $content ),
				'Karma' => 0 // this isn't used yet
				);
		}

		// echo ' title: ',$postdata['Title'];

		$authordata = get_userdata($postdata['Author_ID']);

to


$postdata = array (
				'ID' => 0, 
				'Author_ID' => $preview_userid,
				'Date' => $post_date,
				'Status' => $post_status,
				'Lang' =>  $post_lang,
				'Content' => $content,
				'Title' => $post_title,
				'Url' => $post_url,
				'Category' => $post_category,
				'AutoBR' => $post_autobr,
				'Flags' => array(),
				'Wordcount' => bpost_count_words( $content ),
//begin custom field and mood hack
				'Karma' => 0, // this isn't used yet
				'currentmood' => $post_mood,
				'customfield1' => $post_customfield1,
				'customfield2' => $post_customfield2,
//end custom field and mood hack
				);
		}

		// echo ' title: ',$postdata['Title'];

		$authordata = get_userdata($postdata['Author_ID']);

the next file is admin/edit_actions.php

change


case 'post':
	/*
	 * --------------------------------------------------------------------
	 * INSERT POST & more
	 */
	param( 'post_category', 'integer', true );
	$blog = get_catblog($post_category); 

	$title = T_('Adding new post...');
	require(dirname(__FILE__).'/_menutop.php');
	require(dirname(__FILE__).'/_menutop_end.php');

	param( "post_autobr", 'integer', 0 );
	param( "post_pingback", 'integer', 0 );
	param( 'trackback_url', 'string' );
	$post_trackbacks = & $trackback_url;
	param( 'content', 'html' );
	param( 'post_title', 'html' );
	param( 'post_url', 'string' );
	param( 'post_status', 'string', 'published' );
	param( 'post_extracats', 'array', array() );
	param( 'post_lang', 'string', $default_language );

	if(($user_level > 4) && $edit_date)

to


case 'post':
	/*
	 * --------------------------------------------------------------------
	 * INSERT POST & more
	 */
	param( 'post_category', 'integer', true );
	$blog = get_catblog($post_category); 

	$title = T_('Adding new post...');
	require(dirname(__FILE__).'/_menutop.php');
	require(dirname(__FILE__).'/_menutop_end.php');

	param( "post_autobr", 'integer', 0 );
	param( "post_pingback", 'integer', 0 );
	param( 'trackback_url', 'string' );
	$post_trackbacks = & $trackback_url;
	param( 'content', 'html' );
	param( 'post_title', 'html' );
	param( 'post_url', 'string' );
	param( 'post_status', 'string', 'published' );
	param( 'post_extracats', 'array', array() );
	param( 'post_lang', 'string', $default_language );

// begin custom fields and mood hack

	param( 'post_customfield1', 'string' );
	param( 'post_customfield2', 'string' );
	param( 'post_currentmood', 'integer', 0 );

// end custom fields and mood hack

	if(($user_level > 4) && $edit_date) 

and change


	// INSERT NEW POST INTO DB:
	$post_ID = bpost_create( $user_ID, $post_title, $content, $post_date, $post_category,	$post_extracats, $post_status, $post_lang, '',	$post_autobr, $pingsdone, $post_url ) or mysql_oops($query);

	if (isset($sleep_after_edit) && $sleep_after_edit > 0) 

to


	// INSERT NEW POST INTO DB:

// begin custom fields and mood hack

	$post_ID = bpost_create( $user_ID, $post_title, $content, $post_date, $post_category,	$post_extracats, $post_status, $post_lang, '',	$post_autobr, $pingsdone, $post_url, $post_currentmood, $post_customfield1, $post_customfield2 ) or mysql_oops($query);

// end custom fields and mood hack

	if (isset($sleep_after_edit) && $sleep_after_edit > 0) 

change


case 'editpost':
	/*
	 * --------------------------------------------------------------------
	 * UPDATE POST 
	 */
	$title = T_('Updating post...');
	require(dirname(__FILE__).'/_menutop.php');
	require(dirname(__FILE__).'/_menutop_end.php');
	
	if ($user_level == 0)
	die ("Cheatin' uh ?");

	param( "post_ID", 'integer', true );
	param( "post_category", 'integer', true );
	$blog = get_catblog($post_category); 
	param( "post_autobr", 'integer', 0 );
	param( "post_pingback", 'integer', 0 );
	param( 'trackback_url', 'string' );
	$post_trackbacks = $trackback_url;
	param( 'content', 'html' );
	param( 'post_title', 'html' );
	param( 'post_url', 'string' );
	param( 'post_status', 'string', 'published' );
	param( 'post_extracats', 'array', array() );
	param( 'post_lang', 'string', $default_language );

	$postdata = get_postdata($post_ID) or die(T_('Oops, no post with this ID.'));

to


case 'editpost':
	/*
	 * --------------------------------------------------------------------
	 * UPDATE POST 
	 */
	$title = T_('Updating post...');
	require(dirname(__FILE__).'/_menutop.php');
	require(dirname(__FILE__).'/_menutop_end.php');
	
	if ($user_level == 0)
	die ("Cheatin' uh ?");

	param( "post_ID", 'integer', true );
	param( "post_category", 'integer', true );
	$blog = get_catblog($post_category); 
	param( "post_autobr", 'integer', 0 );
	param( "post_pingback", 'integer', 0 );
	param( 'trackback_url', 'string' );
	$post_trackbacks = $trackback_url;
	param( 'content', 'html' );
	param( 'post_title', 'html' );
	param( 'post_url', 'string' );
	param( 'post_status', 'string', 'published' );
	param( 'post_extracats', 'array', array() );
	param( 'post_lang', 'string', $default_language );

// begin custom fields and mood hack

	param( 'post_customfield1', 'string' );
	param( 'post_customfield2', 'string' );
	param( 'post_currentmood', 'integer', 0 );

// end custom fields and mood hack

	$postdata = get_postdata($post_ID) or die(T_('Oops, no post with this ID.'));

and change


	// UPDATE POST IN DB:
	bpost_update( $post_ID, $post_title, $content, $post_date, $post_category, $post_extracats, 	$post_status, $post_lang, '',	$post_autobr, $pingsdone, $post_url ) or mysql_oops($query);

	if (isset($sleep_after_edit) && $sleep_after_edit > 0) 

to


	// UPDATE POST IN DB:
// begin custom field and mood hack
	bpost_update( $post_ID, $post_title, $content, $post_date, $post_category, $post_extracats, 	$post_status, $post_lang, '',	$post_autobr, $pingsdone, $post_url, $post_currentmood, $post_customfield1, $post_customfield2 ) or mysql_oops($query);
// end custom field and mood hack
	if (isset($sleep_after_edit) && $sleep_after_edit > 0)

the next file is admin/b2edit.php

change


case "edit":
	/*
	 * --------------------------------------------------------------------
	 * Display post editing form
	 */
	param( 'post', 'integer', true );
	$postdata = get_postdata($post) or die( T_('Oops, no post with this ID.') );
	$post_lang = $postdata['Lang'];
	$cat = $postdata['Category'];
	$blog = get_catblog($cat); 

	$title = T_('Editing post');
	require (dirname(__FILE__).'/_menutop.php');
  echo "#".$postdata["ID"]." in blog: ".$blogname;
	require (dirname(__FILE__).'/_menutop_end.php');

	if ($user_level > 0) 
	{
		$authordata = get_userdata($postdata['Author_ID']);
		if ($user_level < $authordata['user_level'])
			die("You don't have the right to edit <strong>".$authordata['user_login']."</strong>'s posts.");

		$edited_post_title = format_to_edit($postdata['Title']);
		$post_url = format_to_edit( $postdata['Url'] );
		$autobr = $postdata['AutoBR'];
		$content = format_to_edit( $postdata['Content'], $autobr );
		$post_pingback = 0;
		$post_trackbacks = '';
		$post_status = $postdata['Status'];
		$post_extracats = postcats_get_byID( $post );
		$edit_date = 0;
		$aa = mysql2date('Y', $postdata['Date']);

to


case "edit":
	/*
	 * --------------------------------------------------------------------
	 * Display post editing form
	 */
	param( 'post', 'integer', true );
	$postdata = get_postdata($post) or die( T_('Oops, no post with this ID.') );
	$post_lang = $postdata['Lang'];
	$cat = $postdata['Category'];
	$blog = get_catblog($cat); 

	$title = T_('Editing post');
	require (dirname(__FILE__).'/_menutop.php');
  echo "#".$postdata["ID"]." in blog: ".$blogname;
	require (dirname(__FILE__).'/_menutop_end.php');

	if ($user_level > 0) 
	{
		$authordata = get_userdata($postdata['Author_ID']);
		if ($user_level < $authordata['user_level'])
			die("You don't have the right to edit <strong>".$authordata['user_login']."</strong>'s posts.");

		$edited_post_title = format_to_edit($postdata['Title']);
		$post_url = format_to_edit( $postdata['Url'] );
		$autobr = $postdata['AutoBR'];
		$content = format_to_edit( $postdata['Content'], $autobr );
		$post_pingback = 0;
		$post_trackbacks = '';
		$post_status = $postdata['Status'];
		$post_extracats = postcats_get_byID( $post );
		$edit_date = 0;
// begin custom fields and mood hack

		$customfield1 = $postdata['customfield1'];
		$customfield2 = $postdata['customfield2'];
		$currentmood = $postdata['currentmood'];


// end custom fields and mood hack
		$aa = mysql2date('Y', $postdata['Date']);

and change


		$action='post';
		
		// These are bookmarklet params:
		param( 'popuptitle', 'string', '' );
		param( 'popupurl', 'string', '' );
		param( 'text', 'html', '' );

		param( 'editing', 'integer', 0 );
		param( 'post_autobr', 'integer', ($editing ? 0 : $autobr ) );	// Use real default only if we weren't already editing
		$autobr = $post_autobr;
		param( 'post_pingback', 'integer', 0 );
		param( 'trackback_url', 'string' );
		$post_trackbacks = & $trackback_url;
		param( 'content', 'html', $text );
		$content = format_to_edit( $content, false );
		param( 'post_title', 'html', $popuptitle );
		$edited_post_title = format_to_edit( $post_title, false );
		param( 'post_url', 'string', $popupurl );
		$post_url = format_to_edit( $post_url, false );
		param( 'post_status', 'string',  $default_post_status );		// 'published' or 'draft' or ...
		param( 'post_extracats', 'array', array() );
		param( 'post_lang', 'string', $default_language );

		param( 'edit_date', 'integer', 0 );
		param( 'aa', 'string', date( 'Y', $localtimenow) );

to


		$action='post';
		
		// These are bookmarklet params:
		param( 'popuptitle', 'string', '' );
		param( 'popupurl', 'string', '' );
		param( 'text', 'html', '' );

		param( 'editing', 'integer', 0 );
		param( 'post_autobr', 'integer', ($editing ? 0 : $autobr ) );	// Use real default only if we weren't already editing
		$autobr = $post_autobr;
		param( 'post_pingback', 'integer', 0 );
		param( 'trackback_url', 'string' );
		$post_trackbacks = & $trackback_url;
		param( 'content', 'html', $text );
		$content = format_to_edit( $content, false );
		param( 'post_title', 'html', $popuptitle );
		$edited_post_title = format_to_edit( $post_title, false );
		param( 'post_url', 'string', $popupurl );
		$post_url = format_to_edit( $post_url, false );
		param( 'post_status', 'string',  $default_post_status );		// 'published' or 'draft' or ...
		param( 'post_extracats', 'array', array() );
		param( 'post_lang', 'string', $default_language );
// begin custom fields and mood hack

		param( 'post_customfield1', 'string' );
		param( 'post_customfield2', 'string' );
		param( 'post_mood', integer, 0 );

// end custom fields and mood hack

		param( 'edit_date', 'integer', 0 );
		param( 'aa', 'string', date( 'Y', $localtimenow) );

now open admin/_edit_form.php

change


		{	// --------------------------- TRACKBACK --------------------------------------
	?>
	<label for="trackback"><strong><?php echo T_('Trackback URLs') ?>:</strong> <span class="notes"><?php echo T_('(Separate by space)') ?></span></label><br /><input type="text" name="trackback_url" class="large" id="trackback_url" tabindex="8" value="<?php echo format_to_edit( $post_trackbacks ); ?>" />
	<?php 
		}
	}
	
	if($use_preview && ($action != 'editcomment') ) 

to


		{	// --------------------------- TRACKBACK --------------------------------------
	?>
	<label for="trackback"><strong><?php echo T_('Trackback URLs') ?>:</strong> <span class="notes"><?php echo T_('(Separate by space)') ?></span></label><br /><input type="text" name="trackback_url" class="large" id="trackback_url" tabindex="8" value="<?php echo format_to_edit( $post_trackbacks ); ?>" />
	<?php 
		}
	}

// begin custom fields and mood hack
	
	?>
	
	<label for="currentmood"><strong><?php echo T_('Current Mood') ?>:</strong></label> <select name="post_currentmood">
                	       <?php displayMoodList($currentmood); ?>
                       		</select>
	<br />

	<label for="customfield1"><strong><?php echo T_('Custom Field 1') ?>:</strong></label> <input name="post_customfield1" type="text" size="50" tabindex="25" value="<?php echo $customfield1; ?>" /><br />
	
	<label for="customfield2"><strong><?php echo T_('Custom Field 2') ?>:</strong></label> <input name="post_customfield2" type="text" size="50" tabindex="26" value="<?php echo $customfield2; ?>" /><br />
	
	<?php

// end custom fields and mood hack

	if($use_preview && ($action != 'editcomment') )  

now the last thing to do:
create a new file and call it moodlist.txt

insert this in the file


Good:1
Great:2
Cool:3
Devilish:4
Evil:5
Embarrassed:6
Angry:7
Furious:8
Sick:9
Confused:10
Astonished:11
Tired:12
Light Headed:13
Asleep:14
Aggravated:15
Amused:16
Annoyed:17
Awake:18
Anxious:19
Bored:20
Hyper:21
Estatic:22
Happy:23
Greatful:24
Hopeful:25
Lazy:26
Nervous:27
Relaxed:28
Scared:29
Excited:30

upload this file in the directory your $baseurl points to.

hopefully i didn't miss anything. any feedback would be great

2 Mar 15, 2004 19:29

oh, well to access this fields you can use something like this in your skins


		<?php display_currentmood('current mood: ',' - '); ?>
		<?php display_customfield1('listing to: '); ?>
                  <?php display_customfield2(); ?> 

3 Mar 25, 2004 13:56

small update:

replace the functions display_currentmood, display_customfield1, display_customfield2 and displayMood with this slightly modified functions


function displayMood($num) {
         //finds the mood $num is and echo's the 
         //associated html code for the mood and image
	 global $baseurl;
	 
         $AllMoods = file($baseurl.'/inc/moodlist.txt');
         foreach($AllMoods as $line_num=>$AMood) {
	 $data = explode(":",$AMood);
	// echo "$data[1] = $num" ;
             if (number_format($data[1]) == number_format($num)) {
                   // echo $data[0] ."&<img src=\"mood/" .strtolower($data[0]) .".gif\" alt=\"(" .$data[0] .")\">";
                   return $data[0];
                  break; //find first entry only and quit
		}
         }
}

function display_currentmood ($before = '', $after = '') {
	global $postdata; 
	
	$currentmood = $postdata['currentmood'];

	if ($currentmood != 0) { 
		echo format_to_output( $before.displayMood($currentmood).$after, 'htmlbody' );  
	}
	
	return;
	
}

function display_customfield1 ($before = '', $after = '') {
	global $postdata; 
	
	$customfield1 = $postdata['customfield1'];

	if ($customfield1 != '') { 
		echo format_to_output( $before.$customfield1.$after, 'htmlbody' );  
	}
	
	return;
	
}

function display_customfield2 ($before = '', $after = '') {
	global $postdata; 
	
	$customfield2 = $postdata['customfield2'];

	if ($customfield2 != '') {
		echo format_to_output( $before.$customfield2.$after, 'htmlbody' );  
	}
	
	return;
	
}

4 Jun 19, 2004 09:12

Does anyone know if this hack run with Version 0.9.0.8?

5 Jun 19, 2004 09:57

Masta_O wrote:

Does anyone know if this hack run with Version 0.9.0.8?

it won't.

6 Jun 19, 2004 21:35

kiesow wrote:

Masta_O wrote:

Does anyone know if this hack run with Version 0.9.0.8?

it won't.

Thx for answer.

So are you releasing a new in the next time?

7 Jun 19, 2004 22:03

Masta_O wrote:

So are you releasing a new in the next time?

am going to, but don't ask me why. maybe next week, i have to fix some things, make some things a little bit more secure and so on.

8 Jul 05, 2004 04:56

Did anyone ever get this working in the oslo 0.9.8 release?

9 Jul 25, 2004 00:52

Sorry, for pushing this thread, but i hope that anyone is releasing an working version vor b2 evo 0.9.0.10

Thanks!

10 Aug 18, 2004 06:31

Okay, I have a problem. My current mood etc. will show up in the preview window but not when I view the blog itself. What's wrong?

11 Aug 18, 2004 07:31

As is said before, this hack isn't compatible with any recent version of b2evolution, so it's probably best to go back and restore your backup (you did make a backup, didn't you?).

12 Aug 18, 2004 21:37

Isn't it compatable with 0.8.6.2?? It was released before this topic was posted.

13 Aug 18, 2004 22:37

Probably not. 0.8.6.2 hasn't been supported for about six months now, so I haven't looked at it - not even sure if I still have a copy lying round even. I think this is 0.8.7 or 0.8.9 - don't quote me on that though.

Seriously, if you're still using 0.8.6.2, you're missing out on over six months of development, and tonnes of new features.

14 Aug 18, 2004 23:07

Haha...
"tonnes"

You brits are so funny with your colorful euro-spelling. :p

15 Aug 18, 2004 23:13

the hack has been written and tested with 0.8.7


Form is loading...