Jump to content

Is anyone here familiar with Joomla?


music_lp90
 Share

Recommended Posts

Hi, I am working on a Joomla site and I am trying to create a custom Mambot that counts down to the end of a sale. I have the mambot so that it will display on the page, but only in the first position, I cannot figure out how to make the mambot display only when the trigger {mosCountdown} has been entered into the content text editor of Joomla. I am working on Joomla version 1.0.14.Here's the code I have:

<?phpdefined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); $option = trim( mosGetParam( $_REQUEST, 'option', null ) );$task = trim( mosGetParam( $_REQUEST, 'task', null ) );$id = intval( mosGetParam( $_REQUEST, 'id', null ) ); $_MAMBOTS->registerFunction( 'onPrepareContent', 'countdownBot' ); function countdownBot( $published, &$row, &$params, $page=0  ) {	// simple performance check to determine whether bot should process further	if ( strpos( $row->text, 'mosCountdown' ) === false ) {		return true;	}	// expression to search for	$find ="{mosCountdown}"; 	if (!$published) {	return true;	} 	// replace text	preg_replace( $find, countDown(), $row->text );		return true;	}?> <?php function showCounter(){	echo "var int=self.setInterval(\"countDown()\", 50);";}?><script type="text/javascript" language="javascript"><!--function countDown(){	var months			= new Array("January", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")	var rightNow 		= new Date();	var hours 			= rightNow.getHours();	var mins 			= rightNow.getMinutes();	var sec				= rightNow.getSeconds();	var year			= rightNow.getFullYear();	var month			= rightNow.getMonth() + 1;	var day				= rightNow.getDate();	var daysInMonth 	= 32 - new Date(year, month -1, 32).getDate();	var daysLeftinMonth = daysInMonth - day;	var targetDate  	= new Date("March 31, 2008 23:59:59");	var targetMonth		= targetDate.getMonth() + 1;	var am_pm			= "AM";	var variableMonth 	= new Date();	var variabledaysInMonth=0;	var daysUntilExpire; //Calculated below counts how many days from now until the expiration date	var hoursUntilExpire;	var secondsInADay	= 24*60*60;		for (var i = month; i < targetMonth-1; i++){		if (i < 10){			i = "0" + i;		}		variabledaysInMonth += 32 - new Date(year, i, 32).getDate();	}	//EXPIRATION CALCULATIONS	daysUntilExpire = variabledaysInMonth + daysLeftinMonth + targetDate.getDate();	var secondsInFullDays = daysUntilExpire*24*60*60;	var secondsToday 	= (hours*60*60) + mins*60 + sec;	var secondsLeft 	= secondsInADay - secondsToday + secondsInFullDays;	var countDays 		= Math.floor(secondsLeft/60/60/24);	var countHours 		= Math.floor((secondsLeft - countDays*secondsInADay)/60/60);	var countMins		= Math.floor((secondsLeft - (countDays*secondsInADay + countHours*60*60))/60);	var countSeconds	= secondsLeft - (countDays*secondsInADay + countHours*60*60 + countMins*60);	//Time conversions	if (hours > 12){		hours-=12;		am_pm = "PM";	}	if (mins < 10){		mins = "0" + mins;	}	if (countSeconds < 10){		countSeconds = "0" + countSeconds;	}	document.getElementById("displayClock").innerHTML = countDays + " days " + countHours + " hours " + countMins + " minutes and " + countSeconds + " seconds ";}<?php	if ($option == "com_magazine") {		showCounter();	} else {		echo "closeCountdown()";	}?>//--></script><script language="javascript" type="text/javascript"><!--function closeCountdown(){	document.getElementById("show").innerHTML = "";	clearInterval(int); }//--></script><?php	if ($option == "com_magazine") {?><!--Hide or show Div --><div id="show">	<!-- CONTAIN AND POSITION -->	<div  id="containCount">		<div id="containCountBody" style="color: #333300;">        	<p style="font-size:12px; text-align:center; color:#993300;"><a href="http://localhost/index.php?option=com_content&task=view&id=172&Itemid=1"><b>Only <span id="displayClock">				</span>			<!--<a href="java script:closeCountdown()"><img src="http://localhost/images/stories/PresSaleAd.jpg" border="0" style="padding: 0px 0px 2px 2px; "></a>-->			 Left on the President's Deal!</b></a></p>		</div>	</div></div><?php	} else {		echo "";	}?>

Thanks for any help!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...