Multiforum mod and multiforum scrolling recentposts.

Started by MarkJ, May 19, 2007, 08:03:28 AM

Previous topic - Next topic

MarkJ

If you have the multi forum mod for Joomla installed you can have a scrolling box that shows recent posts from any forum.  I did it like this:

Iframe code to hold the recent post files:
<iframe name="box" id="box" frameBorder="0" width="168" height="125" src="../media/smf/recentposts1.php" align="middle" scrolling="no"></iframe>

recentposts1.php file has this coding:
<?php
require(dirname(__FILE__) . '/SSIdaoc.php');
?>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" media="all" href="http://bluesplayer.co.uk/css/style.css" />
<style type="text/css">

/* CSS for my first scrolling box */
html,body{
margin:0px;
padding:0px;
}

#scrollingContent{

background:white;
font-weight:bold;
line-height:12px;
font-size:11px;
width:170px;

}


#scrollingContent2{
font-size:1;
}
</style>
<script type="text/javascript">
/************************************************************************************************************
(C) www.dhtmlgoodies.com, November 2005

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/

var slideTimeBetweenSteps = 50; // General speed variable (Lower = slower)


var scrollingContainer = false;
var scrollingContent = false;
var containerHeight;
var contentHeight;

var contentObjects = new Array();
var originalslideSpeed = false;
function slideContent(containerId)
{
var topPos = contentObjects[containerId]['objRef'].style.top.replace(/[^\-0-9]/g,'');
topPos = topPos - contentObjects[containerId]['slideSpeed'];
if(topPos/1 + contentObjects[containerId]['contentHeight']/1<0)topPos = contentObjects[containerId]['containerHeight'];
contentObjects[containerId]['objRef'].style.top = topPos + 'px';
setTimeout('slideContent("' + containerId + '")',slideTimeBetweenSteps);

}

function stopSliding()
{
var containerId = this.id;
contentObjects[containerId]['slideSpeed'] = 0;
}

function restartSliding()
{
var containerId = this.id;
contentObjects[containerId]['slideSpeed'] = contentObjects[containerId]['originalSpeed'];

}
function initSlidingContent(containerId,slideSpeed)
{
scrollingContainer = document.getElementById(containerId);
scrollingContent = scrollingContainer.getElementsByTagName('DIV')[0];

scrollingContainer.style.position = 'relative';
scrollingContainer.style.overflow = 'hidden';
scrollingContent.style.position = 'relative';

scrollingContainer.onmouseover = stopSliding;
scrollingContainer.onmouseout = restartSliding;

originalslideSpeed = slideSpeed;

scrollingContent.style.top = '0px';

contentObjects[containerId] = new Array();
contentObjects[containerId]['objRef'] = scrollingContent;
contentObjects[containerId]['contentHeight'] = scrollingContent.offsetHeight;
contentObjects[containerId]['containerHeight'] = scrollingContainer.clientHeight;
contentObjects[containerId]['slideSpeed'] = slideSpeed;
contentObjects[containerId]['originalSpeed'] = slideSpeed;

slideContent(containerId);

}
</script>
</head>

<div id="scrollingContainer">
<div id="scrollingContent">
<br><br><br><br><br><br><br>
Latest 2 Forum Posts:
<hr color="#C0C0C0" size="1">
<?php ssi_recentPosts(); flush(); ?>
<hr color="#C0C0C0" size="1">
Latest Offers (2 each):
<hr color="#C0C0C0" size="1">
<a target="_top" href="http://bluesplayer.co.uk/homejoomla/index.php?option=com_smf&Itemid=26&forum=computers&board=229.0">Computers (7)</a>:
<?php include("latestofferscomps.php"); ?>
<hr color="#C0C0C0" size="1">
<a target="_top" href="http://bluesplayer.co.uk/homejoomla/index.php?option=com_smf&Itemid=26&forum=mobiles&board=211.0">Mobiles Phones (5)</a>
<?php include("latestoffersmobiles.php"); ?>
<hr color="#C0C0C0" size="1">
<a target="_top" href="http://bluesplayer.co.uk/homejoomla/index.php?option=com_smf&Itemid=26&forum=musicians&board=293.0">Musical (5)</a>:
<?php include("latestoffersmusic.php"); ?>
<hr color="#C0C0C0" size="1">
<a target="_top" href="http://bluesplayer.co.uk/homejoomla/index.php?option=com_smf&Itemid=26&forum=shopping&board=204.0">Shopping (37)</a>:
<?php include("latestoffersshops.php"); ?>
<hr color="#C0C0C0" size="1">
<a target="_top" href="http://bluesplayer.co.uk/homejoomla/index.php?option=com_smf&Itemid=26&forum=software&board=196.0">Software (2)</a>:
<?php include("latestofferssoftware.php"); ?>
</div>
</div>

<script type="text/javascript">
initSlidingContent('scrollingContainer',1);
</script>

</body>
</html>


The SSIdaoc.php file (just a renamed SSI.php file with the recentposts part altered to suit my forum) has been set to show just 2 posts:
function ssi_recentPosts($num_recent = 2, $exclude_boards = null, $output_method = 'echo')


As you can see above 2 posts show (online line 115 of recentposts1.php) with the code:
<?php ssi_recentPosts(); flush(); ?> 

To show the posts from selected forums I use this code (set to show "Computer Hot Deals/Vouchers" by leaving 229 from the array (numbers left in post to help you should you use this):

<?php

require(dirname(__FILE__) . '/SSIdaoc.php');

?>


<?php

$array 
ssi_recentTopics(2, array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300), 'array');

foreach (
$array as $recent)
{
  
$subject html_entity_decode($recent['subject']);
  if (
strlen($subject) > 100)
    
$subject htmlentities(substr($subject0100)) . '...';
  else
    
$subject $recent['subject'];
echo 

<div id="block_recent_posts">
<a target="_top" href="http://bluesplayer.co.uk/homejoomla/index.php?option=com_smf&Itemid=26&forum=computers&board=229.0" style="color: #7a7a3d;"><i>Computer Hot Offers</i></a><br>
<a target="_top" href="'
$recent['href'], '" title="Board: '$recent['board']['name'], ' - Poster: '$recent['poster']['name'], '">'$subject'</a><i> by
<a target="_top" href="http://bluesplayer.co.uk/media/smf/index.php?action=profile;u=18.0" style="color: #7a7a3d;">Admin</i></a>
</div>
'
;
}

?>


If you look at the first batch of code (line 120 of recentposts.php) this file is included with:
<?php include("latestofferscomps.php"); ?>

All I have done to create the other forum posts is to copy this latestofferscomps.php and rename it.  Then I put the 229 back in and removed the number referring to any other forum I wanted to show from the number array.

I have also added lots of other files and have links below the iframe to show the latest 6 offers from forums and also the latest 10 replies from all.  These just load into the iframe.

Works a treat and you can see it on my site on any main page:

http://bluesplayer.co.uk

Hope you can follow this but it isn't really too hard to do.

Regards - Bluesplayer (Mark)

Advertisement: