Jump to content


Showing an SMF post in MKportal ?


3 replies to this topic

#1 Luke

  • Members
  • 2 posts

Posted 21 December 2007 - 05:29 PM

Hi.

I want to display only one post from an SMF forum in a MKPortal block.
Its for a clan site I'm creating and, i want to create a , clan member page to show a post from the forum, so that i can easily edit the post within SMF and it will show in MKportal.

any ideas?

thanks :P

#2 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 24 December 2007 - 08:18 AM

Luke said:

Hi.

I want to display only one post from an SMF forum in a MKPortal block.
Its for a clan site I'm creating and, i want to create a , clan member page to show a post from the forum, so that i can easily edit the post within SMF and it will show in MKportal.

any ideas?

thanks :P
This should be an easy hack. I will try to work on this after the holidays. If I forget please remind me. I think it will only take me 15 minutes. :-)


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard

#3 Luke

  • Members
  • 2 posts

Posted 27 December 2007 - 05:49 PM

Ok thanks for the reply :P

hope to hear from you soon.

#4 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 28 December 2007 - 11:29 AM

OK, try this one. You should paste this code into a new php file and upload it to the mkportal/blocks directory. It is only a modified version of the boardnews block for SMF.

<?php
/*
+--------------------------------------------------------------------------
|   MkPortal
|   ========================================
|   by Meo aka Luponero <Amedeo de longis>
|	  Don K. Colburn <visiblesoul.net>
|
|   Copyright (c) 2004-2007 mkportal.it
|   http://www.mkportal.it
|   Email: luponero@mclink.it
|
+---------------------------------------------------------------------------
|
|   > MKPortal
|   > Written By Amedeo de longis
|   > Date started: 9.2.2004
|
+--------------------------------------------------------------------------
*/
if (!defined("IN_MKP")) {
	die ("Sorry !! You cannot access this file directly.");
}

$out = get_smf_post();

$content = "
				<tr>
				  <td class="contents">
					<div class="taburlo">
					  <table width="100%" border="0" cellspacing="0" cellpadding="2">
					<tr>
					  <td class="taburlo" valign="top">
						{$out}
					  </td>
					</tr>
					  </table>
					</div>
				  </td>
				</tr>
 ";



	function get_smf_post()
	 {
		global $DB, $mklib, $mkportals, $db_prefix, $user_info, $modSettings;

		$user_info['smiley_set'] = $mkportals->member['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set'];

		if (!$user_info['smiley_set']) {
			$user_info['smiley_set'] = "default";
		}
		$limit = "5";
	$news_words= "0";
	$id_message = "1,9";
		//$taglio = 17;
		$db_prefix = DBPREFIX;
		$forum_active = unserialize($mklib->config['forum_active']);
		if(!$forum_active) {
				return "";
		}
		$sql = "SELECT
			m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, m.ID_BOARD,
			IFNULL(mem.realName, m.posterName) AS posterName, t.ID_BOARD, t.numReplies, b.name AS bName,
			m.body, m.smileysEnabled, m.Icon, mem.avatar, av.filename, av.ID_ATTACH
		FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}boards AS b)
			LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
		LEFT JOIN {$db_prefix}attachments AS av ON (mem.ID_MEMBER = av.ID_MEMBER)
			WHERE m.ID_MSG >= " . max(0, $modSettings['maxMsgID'] - 200 * $limit) . "
		AND m.ID_MSG IN ($id_message)
		AND b.ID_BOARD = t.ID_BOARD
		GROUP BY m.ID_MSG
		ORDER BY m.ID_MSG DESC
		LIMIT $limit";

		$DB->query($sql);

		while ( $post = $DB->fetch_row() ) {
	$avatar_img = "";
		  $title = strip_tags($post['subject']);
		$title = str_replace( "!" , "!" ,$title );
		$title = str_replace( """, """, $title );

		 $date  = $mklib->create_date($post['posterTime']);
		$tid = $post['ID_TOPIC'];

		$mid = $post['ID_MEMBER'];
		$mname = $post['posterName'];
		$testo = $post['body'];
	if ($news_words) {
		$testo = substr ($testo, 0, $news_words);
		$testo .= " ...";
   	}
		$testo = doUBBC($testo);
	parsesmileys($testo);
		$fname = $post['bName'];
	$numreplies = $post['numReplies']." ".$mklib->lang['replies'];
		$icona = $mkportals->forum_url."/Themes/default/images/post/".$post['Icon'].".gif";
		$avatar_url = $post['filename'];
	$idattach = $post['ID_ATTACH'];

	if ($avatar_url) {
		$avatar_img = "<img src="{$mkportals->forum_url}/index.php?action=dlattach;attach=$idattach;type=avatar" alt="" border="" />";
	} else  {
		$avatar_url = $post['avatar'];
		if (substr($avatar_url, 0, 7) == 'http://')
			{
				$dimension = url_image_size($avatar_url);
				if ($dimension[0] > 80) {
					$dimension[1] = ceil(80 * $dimension[1] / $dimension[0]);
					$dimension[0] = 80;
				}
				$avatar_img = "<img src="$avatar_url" width="$dimension[0]" height="$dimension[1]" alt="" border="" />";

			} else {

				$avatar_img = "<img src="{$mkportals->forum_url}/avatars/$avatar_url" alt="" border="" />";
			}
	}
	if (!$avatar_url) {
		$avatar_img = "<img hspace="0" src="$icona" align="bottom" border="0" alt="" />";
	}
	$out .= "
					<table class="tabnews" cellspacing="2" cellpadding="2" width="100%">
					  <tbody>
					  <tr>
					<td class="tdblock" align="center" width="5%">
					$avatar_img
					</td>
					<td class="tdblock" valign="middle" align="center" width="95%">
					<b>$fname
<a href="$mkportals->forum_url/index.php?topic=$tid">$title</a></b>
					
<div align="right" style='font-style: italic; font-weight: normal;'><a href="$mkportals->forum_url/index.php?topic=$tid">$numreplies</a> </div>
			</td>
					  </tr>
					  <tr>
					<td colspan="2">

					$testo
					</td>
					  </tr>
					  <tr>
					<td align="right" colspan="2">
					
<i>{$mklib->lang['from']}<b> <a href="$mkportals->forum_url/index.php?action=profile;u=$mid">$mname</a></b>, $date <a href="$mkportals->forum_url/index.php?topic=$tid"> [ {$mklib->lang['readall']} ]</a></i>
					</td>
					  </tr>
					  </tbody>
					</table>
		";
		 }
		return $out;
	 }

?>
To configure the block look at these 3 lines:
		$limit = "5";
	$news_words= "0";
	$id_message = "1,9";
$limit is how many posts you want to display in the block.
$news_words is the test cutoff. 0 is no cutoff
$id_message is the id of the messages you want to display. Separate multiple messages with commas. This example displays message 1 and message 9.

-=DKC=-


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users