EToS
{ ADMIN }
posts: 14
last: 12-Feb-2009
TITLE: How to toggle Controller Dump information with CakePHP
DESCRIPTION: Showing debug information and toggle it at the bottom of a page
Submitted: 23-Sep-2008 11:52:47 ( 1yrs 24w 2d 7h ago ) Language: PHP (*.php *.php4 *.php5 *.phtml)
Views: 856 Lines of Code: 48 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 3.67 / 5 }
Difficulty: Intermediate
Bookmark
/*
You may wish to add your own CSS styles, but this code can be placed at the bottom of a page hidden away untill you require it for debugging

to conditionally show a special debug css page during debug mode you can also use:

<?php  if (Configure::read('debug') > 0) { echo "<link href=\"/css/debug.css\" rel=\"stylesheet\" type=\"text/css\" />"; }  ?>

*/




<!------------ DEBUG VARS/ARRAYS ------------>
<?php

if (Configure::read('debug') > 0)
{
    echo "<div id=\"admin_text2_small\" style=\"clear: both;\"><a href=\"javascript: toggleLayer('footerDebug'), toggleLayer('footerDebugBody'), toggleDebugText();\"><span id=\"toggleDebugText\">Toggle Debug [+]</span></a></div>";
	echo "<div id=\"footerDebug\" style=\"display: none; clear: both; text-align: center; color: #828282\"> Vars / Arrays </div>";
	echo "<div id=\"footerDebugBody\" style=\"display: none; clear: both;\">";

	print_r($cakeDebug);  // dump controller

    /* // output ALL vars/arrays
	$arrayObj = new ArrayObject(get_defined_vars());

	for($iterator = $arrayObj->getIterator(); $iterator->valid(); $iterator->next())
	{
		echo $iterator->key() . ' => ' . $iterator->current() . '<br />';
	}
	*/

	echo "</div>";
}

?>

<script type="text/javascript">
	function toggleDebugText() {
		if (document.getElementById('footerDebug').style.display == 'none')
		{
			document.getElementById('toggleDebugText').innerHTML = 'Toggle Debug [+]';
		} else {
			document.getElementById('toggleDebugText').innerHTML = 'Toggle Debug [-]';
		}
	}
</script>
<!------------ END DEBUG VARS/ARRAYS ------------>