Scripts

Breadcrumbs script

create_location_str( $data, $site_name, $html = array(), $divider = ' ยป ') $data Een array met de locaties. Deze kan je zo lang maken als je wil. De key is de URL, de value zelf is de link-naam. $site_name Je site / forum / paginanaam. Bijvoorbeeld 'PHPHulp' $html Niet verplicht De HTML-codes voor de treebar. Deze zijn standaard ingesteld, maar je kan ze dus aanpassen. Deze vervangt de standaard waarden, dus het maakt niet uit als je eentje openlaat. $divider Niet verplicht Het teken tussen de links door. Opmerking voorbeeld: de get-variable test kan 1 tot 4 zijn. (PS, excuses voor de 'aparte' naam maar ik wist niet hoe dit normaal genoemd word. :P)

breadcrumbs-script
[code]
<?php

if ( $_GET['test'] == 1 )
{
	$data = array(
		'./'	=> 'Homepage'
	);
}
elseif ( $_GET['test'] == 2 )
{
	$data = array(
		'./'				=> 'Homepage',
		'./add.php'			=> 'Add'
	);
}
elseif ( $_GET['test'] == 3 )
{
	$data = array(
		'./'				=> 'Homepage',
		'./add.php'			=> 'Add',
		'./add.php?do=news'	=> 'Add News'
	);
}
else
{
	$data = array(
		'./'							=> 'Homepage',
		'./add.php'						=> 'Add',
		'./add.php?do=news'				=> 'Add News',
		'./add.php?id=3531&fix=poll'	=> 'Add poll',
	);
}

$site_name = 'Wesdesignz';

$html = array(
	0	=> array('<img src="./img/folder_start.png" alt="" />&nbsp;<strong>','</strong>'),
	1	=> array('<a href="{URL}">','</a>'),
	2	=> array('<div><img src="./img/folder_current.png" alt="" class="current" /><h1 class="clr">','</h1></div>'),
	3	=> array('<img src="./img/folder_start.png" alt="" />&nbsp;<a href="{URL}">','</a>'),
);

$divider = ' &raquo; ';

function create_location_str( $data, $site_name, $html = array(), $divider = ' &raquo; ')
{
	$dhtml = array(
		0	=> array('<img src="./img/folder_start.png" alt="" />&nbsp;<strong>','</strong>'),
		1	=> array('<a href="{URL}">','</a>'),
		2	=> array('<div><img src="./img/folder_current.png" alt="" class="current" /><h1 class="clr">','</h1></div>'),
		3	=> array('<img src="./img/folder_start.png" alt="" />&nbsp;<a href="{URL}">','</a>'),
	);
	for( $i = 0; $i <= 4; $i++ )
	{
		if ( $html[$i] == '' && $html[$i] == NULL )
		{
			$html[$i] = $dhtml[$i];
		}
	}
	
	if ( is_array( $data ) )
	{
		$count = count( $data );
		if ( $count == 1 )
		{
			return $html[0][0] . $site_name . $html[0][1];
		}
		else
		{
			$return = null;
			$i = 1;
			foreach( $data as $href => $name )
			{
				if ( $i == 1 )
				{
					$return .= str_replace('{URL}', $href, $html[3][0] ) . $site_name . $html[3][1];
				}
				elseif ( $i == $count )
				{
					$return .= str_replace('{URL}', $href, $html[2][0] ) . $name . $html[2][1];
				}
				else
				{
					$return .= str_replace('{URL}', $href, $html[1][0] ) . $name . $html[1][1];
				}
				
				if ( $i < $count )
				{
					$return .= $divider;
				}
				
				$i++;
			}
			return $return;
		}
	}
	else
	{
		return '$data wasn\'t an array.';
	}
}

$clr = create_location_str( $data, $site_name, $html, $divider );

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="nl">
<head>
	<!-- no cache headers -->
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="-1" />
	<meta http-equiv="Cache-Control" content="no-cache" />
	<!-- end no cache headers -->
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="keywords" content="Wesdesignz" />

	<meta name="description" content="Wesdesignz" />
	<!-- CSS Stylesheet -->
	<style type="text/css">
	* {
		margin: 0;
		padding: 0;
		font-family: Trebuchet MS, Verdana, Arial, Sans;
		font-size: 10pt;
	}
	
	body {
		background-color: #AAAAAA;
		padding: 25px;
	}
	
	#clr {
		border: solid #c1c1c1 4px;
		padding: 4px;
		background-color: #FFFFFF;
	}
	
	h1.clr {
		position: relative;
		font-size: 23px;
	}
	
	img.current {
		position: relative;
		float: left;
		margin-top: 5px;
		padding-right: 4px;
		padding-left: 15px;
	}
	
	a,a:visited,a:hover,a:active {
		color: #666666;
		text-decoration: none;
	}
	
	a:hover,a:active {
		color: #888888;
		text-decoration: underline;
	}
	</style>
	<title>Wesdesignz - Rescripting your website!</title>
</head>
<body>
	<div id="clr">
		<?php print $clr; ?>
	</div>
</body>
</html>
[/code]

Reacties

0
Nog geen reacties.