Jump to content


Featured Blog Entries


  • You cannot reply to this topic
3 replies to this topic

#1 Guest_miguelmayo_*

  • Guests

Posted 23 January 2007 - 09:31 AM

I managed to modify unreal portal 2.2 to work with ipc's ipblog 1.3 and ipboard 2.2 as putting up blocks of blog entries like the news block does in the uportal. I had to add a pinning button and setting to the blog, that only an admin with acp admin can see or use. this pins entries to feature on the portal. This took some hacking of the source files along with some mysql inserts to make it work. I have blog settings in the acp too under the portal tab, show, teaser length, and number of entries - code I borrowed from crickets news block and modified to work for the blog system.

you can veiw my portal here to get an idea how it looks

http://www.vfrdiscussion.com


BLOG EDITS

Starting with the blog itself you must add a pinned setting, I use the gallery pin image to great effect if you dont have ipc gallery you can post up and you can make a simple macro for it in the skin section - pin and unpin images to make buttons out of.

adding pinned setting to the database open up your acp and under admin tab>SQL Management> SQL toolbox - scroll down to run a manual query. assuming your using the standard ibf_ prefix for the tables!

ALTER TABLE `ibf_blog_entries` ADD `entry_pin` VARCHAR( 10 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL AFTER `entry_last_vote`;


open up the file /public_html/forum/modules/blog/mod.php - make a backup!!

find the code
case 'dounlock':			$this->do_unlock();


insert below that
//-----added by miguel


			case 'dopin':			$this->do_pin();
												case 'dounpin':			$this->do_unpin();

			//----- end added by miguel



Now find this marker

/*-------------------------------------------------------------------------*/

	// Toggle show/hide Draft

	/*-------------------------------------------------------------------------*/


Directly ABOVE that paste
/*-------------------------------------------------------------------------*/ 
// Pin a Blog Entry added by miguel 
/*-------------------------------------------------------------------------*/ 

function do_pin() 
{ 
if ( !$this->ipsclass->member['g_is_supmod'] ) 
{ 
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_blog_mod_permission' ) ); 
} 

// Did we enter a entry_id? 
$entry_id = intval($this->ipsclass->input['entryid']); 

if (! $entry_id ) 
{ 
$this->ipsclass->Error( array( 'LEVEL'=> 5, 'MSG' =>'incorrect_use') ); 
} 

$entry = $this->ipsclass->DB->build_and_exec_query( array ( 'select' => '*', 
'from' => 'blog_entries', 
'where' => "entry_id = {$entry_id}" 
) ); 

// Check if we got access (and not just trying some id's :P) 
if (empty($entry) or $entry['entry_name']=="") 
{ 
$this->ipsclass->Error( array( 'LEVEL'=> 5, 'MSG' =>'incorrect_use') ); 
} 

// We are good to update 
$this->ipsclass->DB->do_update("blog_entries", array('entry_pin' => pinned ), "entry_id={$entry_id}"); 

$this->add_modlog( "Blog({$this->blog['blog_id']}) '{$this->blog['blog_name']}': Pinned entry '{$entry['entry_name']}'" ); 

// Redirect back to Blog page 
$this->ipsclass->boink_it($this->ipsclass->base_url."act=module&module=blog&req=showblog&blogid={$this->blog_id}"); 
} 

/*-------------------------------------------------------------------------*/ 
// Unpin a Blog Entry added by miguel 
/*-------------------------------------------------------------------------*/ 

function do_unpin() 
{ 
if ( !$this->ipsclass->member['g_is_supmod'] ) 
{ 
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_blog_mod_permission' ) ); 
} 

// Did we enter a entry_id? 
$entry_id = intval($this->ipsclass->input['entryid']); 

if (! $entry_id ) 
{ 
$this->ipsclass->Error( array( 'LEVEL'=> 5, 'MSG' =>'incorrect_use') ); 
} 

$entry = $this->ipsclass->DB->build_and_exec_query( array ( 'select' => '*', 
'from' => 'blog_entries', 
'where' => "entry_id = {$entry_id}" 
) ); 

// Check if we got access (and not just trying some id's :P) 
if (empty($entry) or $entry['entry_name']=="") 
{ 
$this->ipsclass->Error( array( 'LEVEL'=> 5, 'MSG' =>'incorrect_use') ); 
} 

// We are good to update 
$this->ipsclass->DB->do_update("blog_entries", array('entry_pin' => unpinned ), "entry_id={$entry_id}"); 

$this->add_modlog( "Blog({$this->blog['blog_id']}) '{$this->blog['blog_name']}': Unpinned entry '{$entry['entry_name']}'" ); 

// Redirect back to Blog page 
$this->ipsclass->boink_it($this->ipsclass->base_url."act=module&module=blog&req=showblog&blogid={$this->blog_id}"); 
}


Save mod.php and upload



Open the file /public_html/forum/modules/blog/show.php - make a backup!!

find the code below around line 1339
$entry['lock'] = "";

		if ( !$entry['entry_locked'] && $this->blog_std->allow_locking( $this->blog ) )

		{

			$entry['lock'] = "<A href="\"{$this-">ipsclass->vars['blog_url']}req=dolock&entryid={$entry['entry_id']}&auth_key={$this->ipsclass->md5_check}\"><{P_LOCK}>";

		}

		if ( $entry['entry_locked'] && $this->blog_std->allow_locking( $this->blog ) )

		{

			$entry['lock'] = "<A href="\"{$this-">ipsclass->vars['blog_url']}req=dounlock&entryid={$entry['entry_id']}&auth_key={$this->ipsclass->md5_check}\"><{P_UNLOCK}>";

		}


Directly below that add
//------------------- pin entry added by miguel

		if ( $this->ipsclass->member['g_is_supmod'] )

		{	

			$entry['pinned'] = "";

			if ( $entry['entry_pin'] !== "pinned" )

			{

			$entry['pinned'] = "<A href="\"{$this-">ipsclass->vars['blog_url']}req=dopin&entryid={$entry['entry_id']}&auth_key={$this->ipsclass->md5_check}\"><{GALLERY_PIN}>";

			}

			if ( $entry['entry_pin'] == "pinned" )

			{

			$entry['pinned'] = "<A href="\"{$this-">ipsclass->vars['blog_url']}req=undopin&entryid={$entry['entry_id']}&auth_key={$this->ipsclass->md5_check}\"><{GALLERY_UNPIN}>";

			}

		}

		//--------------------end pinned


save and upload show.php this concludes the code to pin a blog entry.


IF YOU DO NOT HAVE IPC gallery!! how to make a macro!

Again if you do not have gallery you will have to make a macro to replace the macros I used above, with the look and feel>Skins & Templates>Skin Manager - click on skin set you use and then click "Edit Replacement Macros" in the drop down menu. upload these two images to the folder (where /1/ can be changed to the directory you chose, /1/ is the default image folder ipc board uses) or make your own images if your using a custom skin its your perogative! I just used the gallery macros that were already availible to me, saved me some time!

/forum/style_images/1/p_pin.gif Posted Image

and

forum/style_images/1/p_unpin.gif Posted Image

<{GALLERY_UNPIN}> and <{GALLERY_PIN}>


Makeing a macro is pretty simple

click "add macro" at the bottom. to make a new pin button macro

In the variable box paste
GALLERY_PIN


In the replacement box paste
<img src='style_images/<#IMG_DIR#>/p_pin.gif' border='0' alt='Pin' />


do the same for an unpin button! click "add macro" at the bottom.

In the variable box paste
GALLERY_UNPIN


In the replacement box paste
<img src='style_images/<#IMG_DIR#>/p_unpin.gif' border='0' alt='Unpin' />


Done with macros *if you dont use the ipc gallery*


UNREAL PORTAL EDITS
Now onto the unreal portal 2.2! These edits are for ipc board 2.2 and ipc blog 1.3! The latest versions of each!

Adding new settings for unreal portal requires more database inserts. open up your acp and under admin tab>SQL Management> SQL toolbox - scroll down to run a manual query. assuming your using the standard ibf_ prefix for the tables!

INSERT INTO `ibf_unrealportal` (`id`, `name`, `title`, `align`, `show`, `order2`) VALUES ('40', 'blog', 'Blog Entry', 'middle', '1', '0');
INSERT INTO `ibf_up_settings` (`name`, `value`) VALUES ('blog_tease_length', '400');
INSERT INTO `ibf_up_settings` (`name`, `value`) VALUES ('entry', '1');



open up the file /public_html/forum/sources/action_admin/uportal.php - make a backup!!

find the code near line 274
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Poll" );

		$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>Portal Poll</b><br>Select an thread (only threads WITH an poll are shown)." ,
										  $this->ipsclass->adskin->form_dropdown( "poll", $top_polls , $GLOBALS['setting']['poll'] )
								 )	  );

		$this->ipsclass->html .= $this->ipsclass->adskin->end_table();


add below that
//--------------------Added by Miguel

		$this->ipsclass->adskin->td_header[] = array( " "   , "40%" );
		$this->ipsclass->adskin->td_header[] = array( " "   , "60%" );

		$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Blogs" );

		$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>Show Blog Entry?</b>" ,
										  $this->ipsclass->adskin->form_yes_no( "blog", $GLOBALS['block']['blog']  )

								 )	  );

		$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>How many Blog entries to show at the front page?</b>" ,
										  $this->ipsclass->adskin->form_input( "entry", $GLOBALS['setting']['entry']  )
								 )	  );
  
		$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>How many charactors to show?</b>" ,
										  $this->ipsclass->adskin->form_input( "blog_tease_length", $GLOBALS['setting']['blog_tease_length']  )
								 )	  );

		$this->ipsclass->html .= $this->ipsclass->adskin->end_table();

		//----------------------end added by Miguel

Save and upload /public_html/forum/sources/action_admin/uportal.php



You can now click the portal tab> portal main - and see the settings, edit them as you wish, how many entrys to show, how many charactors to reveal, then move the blocks using the "organize blocks" section look for the block "Blog Entry" move it where you wish.

open the file /public_html/forum/sources/action_public/uportal.php

find the marker near line 384
//Top Forums


add ABOVE THAT
//--------------------------------------------------
		// Blogs added by Miguel
		//--------------------------------------------------

		if($GLOBALS['block']['blog'] != 0)
		{
			$count = 0;
			$max = $GLOBALS['setting']['entry'];

		

			$limit = $maxcount + 20;

			$query = $this->ipsclass->DB->query	  ("SELECT ibf_blog_entries.entry_id, ibf_blog_entries.entry_author_id, ibf_blog_entries.entry_author_name, ibf_blog_entries.entry_date, ibf_blog_entries.entry_name, ibf_blog_entries.entry, ibf_blog_entries.entry_status, ibf_blog_entries.entry_locked, ibf_blog_entries.entry_num_comments, ibf_blog_entries.entry_html_state, ibf_blog_entries.entry_pin, ibf_blog_blogs.blog_num_views, ibf_blog_blogs.blog_id											  
													FROM ibf_blog_entries, ibf_blog_blogs
													WHERE entry_status = CONVERT( _utf8 'published' USING latin1 ) 
													COLLATE latin1_swedish_ci
													AND entry_locked !=1
													AND entry_pin = CONVERT( _utf8 'pinned' USING latin1 ) 
													COLLATE latin1_spanish_ci 
													AND ibf_blog_entries.blog_id = ibf_blog_blogs.blog_id 
													ORDER BY entry_id DESC LIMIT {$limit}");

			while($fetch = $this->ipsclass->DB->fetch_row($query))
			{
					$fetch[entry_name] = ($this->ipsclass->lang['blog_main'].$fetch[entry_name]);
					$fetch[entry] = substr($fetch[entry], 0, $GLOBALS['setting']['blog_tease_length'])."...";
				{
					$blog[] = $fetch;
					$count++;
				}

				if($count == $max)
					break;
			}
		}

		//---------------------------End Blog added by Miguel


In the section
/*****************
		Start Calling Functions
		*****************/


find
$this->data['news']				= $this->news($news);


Add below that
//added by miguel
		$this->data['blog']				= $this->blog($blog);
		//end added by miguel


Find well below
function no_content()


Directly ABOVE that add
//--------------------------------------
//added by Miguel Blogs
//--------------------------------------
function blog($blog="")
	{
		if($GLOBALS['block']['blog'] == 0)
			return '';

		if($blog != null)
		{
			$total = sizeof($blog);
			$count = 0;
			$this->ipsclass->offset_set = 0;

			if(is_array($blog))
			{

				foreach($blog as $key=>$fetch)
				{
					$count++;
					$this->ipsclass->lang["blog{$fetch['entry_id']}"] = $fetch['entry_name'];

					$output .= $this->ipsclass->compiled_templates['skin_uportal']->block_start(
					$this->collapse("blog{$fetch['entry_id']}"),"blog{$fetch['entry_id']}");

					$this->parser->parse_html  = ($fetch['entry_htmlstate'] ) ? 1 : 0;
					$this->parser->parse_nl2br = $fetch['entry_htmlstate'] == 2 ? 1 : 0;

					if (!$this->ipsclass->member['view_img'])
					{
						//-----------------------------------------
						// unconvert smilies first, or it looks a bit crap.
						//-----------------------------------------
			
						$fetch['entry'] = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , 
							$fetch['entry'] );
			
						$fetch['entry'] = preg_replace( "/<img src=[\"'](.+?)[\"'].+?".">/", 
							"(IMG:<a href='\\1' target='_blank'>\\1</a>)", $fetch['entry'] );
					}

					$fetch['entry'] = $this->parser->pre_display_parse( $fetch['entry'] );
					$fetch['entry_date'] = $this->ipsclass->get_date( $fetch['entry_date'], 'LONG');

					$output .= $this->ipsclass->compiled_templates['skin_uportal']->blog_block($fetch);
				
						if($count == $total)
						$output .= $this->ipsclass->compiled_templates['skin_uportal']->block_end();
					else
						$output .= $this->ipsclass->compiled_templates['skin_uportal']->block_end();

				}
			}
		
			return $output;
		}
	}
//--------------end added by miguel


Save and upload /public_html/forum/sources/action_public/uportal.php


Open the file /public_html/forum/cache/lang_cache/en/lang_uportal.php - make a backup

find -
'calendar'  => "Calendar",


add below that, or where ever you want it to be
//added by miguel
'blog_main'  => "Featured Blog Entry :: ",
'view_blog'	  => "View Blog",
'blog_views'  => "Blog Views",
//end added by miguel


save and upload lang_uportal.php

MAKE A SKIN TEMPLATE

Now we must make a skin template called "blog block" in the box "Skins & Templates" click "Skin Manager" mouse right to the options box of the skin you use! click "edit template HTML" scroll down to "skin_uportal" and click on it!

in the rigth hand box of templates at the very bottom click the box "add template bit"

a new screen will appear "New Template Bit Specifics"
in the box "New Template Bit Name" type/paste
blog_block


in the box "New Template Bit Incoming Data Variables" type/paste
$fetch=""

now click the "continue" button at the bottom of that modual

a text box will open paste in this html
<table class='ipbtable' cellspacing="1">
	<tr>
		<td valign="middle" class='row2'><b>{$this->ipsclass->lang['posted_by']}</b> 
<if="$fetch['entry_author_id'] == 0">
 {$fetch['entry_author_name']}
<else />
 <a href='{$this->ipsclass->base_url}showuser={$fetch['entry_author_id']}'>{$fetch['entry_author_name']}</a>
</if>
			 @ {$fetch['entry_date']}</td>
	</tr>
	<tr>
		<td valign="middle" class='row2'>{$fetch['entry']}<br/></td>
	</tr>
	<tr>
		<td valign="middle" class='row2'>
			<b>{$this->ipsclass->lang['comments']}</b> {$fetch['entry_num_comments']} :: 
			<a href='{$this->ipsclass->base_url}automodule=blog&blogid={$fetch['blog_id']}&showentry={$fetch['entry_id']}'>{$this->ipsclass->lang['view_blog']}</a> :: {$this->ipsclass->lang['blog_views']} :: {$fetch['blog_num_views']} </td>

	</tr>
	<tr>
		<td class="catend" colspan="2"><!-- no content --></td>
	</tr>
</table>



DONE WITH EDITS!!

Now you can visit the blog and pin some entries you want to appear on the portal! they will appear in order of the entry number , go to the acp portal tab and set the number of entries you want to appear, how many charactors to tease (shows only a teaser) and of course set the blogs to show. go to the block organizer and move the blocks to where you want them!

#2 Bartman2

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 10 November 2008 - 05:14 PM

it.s not working - error

#3 Bartman2

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 11 November 2008 - 02:43 AM

Anyone know how to make last 5 blog entries on main portal page?
Thanks

#4 Gerry

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts
  • Gender:Male
  • Location:St Helens - UK -

Posted 18 December 2008 - 07:26 PM

Very nice but now well out of date, Blog 1.4.1 is out and is totally different to 1.3 anyone going to upgrade this.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users