Revision [13925]

This is an old revision of HighlightAction made by SpifFin on 2006-04-25 13:47:13.

 

Highlight text action


This is an embarrassingly simple action to allow highlighted text in a colour of your choice. It is a simple hack of the color action.

There are two versions: one which allows for a pre-defined highlight colour to be used each time, and another which allows for any colour to be entered and displayed.

Version one - single pre-defined highlight colour


Simply copy this code, change the word 'yellow' to any css named colour (e.g. yellow) or hex colour (e.g. #FFFF00), save as highlight.php and upload to the actions directory:

<?php

if (is_array($vars)) {

	foreach ($vars as $param => $value) {
		if ($param == 'text')
		{
		$mytext= $value;
		}

	}
	echo "<span style=\"background-color: yellow\">".$mytext."</span>";
}
?>


To use, simply call the action and define your text, for example:

{{highlight text="my highlighted text"}}


Version two - define the highlight colour each time


Simply copy this code, save as highlight.php and upload to the actions directory:

<?php

if (is_array($vars)) {

	foreach ($vars as $param => $value) {
		if ($param == 'text')
		{
		$mytext= $value;
		}
		if ($param == 'c')
		{
			$colorcode=$value;
		}
		elseif ($param == 'hex')
		{
			$colorcode=$value;
		}

	}
	echo "<span style=\"background-color: $colorcode\">".$mytext."</span>";
}
?>


To use, simply call the action, define your colour (as a css named colour, e.g. yellow, or in hex, e.g. #FFF00) and define your text, for example:

{{highlight c="yellow" text="my highlighted text"}}


or:

{{highlight hex="#FFFF00" text="my highlighted text"}}


Hope someone finds this useful.

SpifFin


CategoryUserContributions
There is one comment on this page. [Display comment]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki