Welcome Guest, Not a member yet? Register   Sign In
how to display contents of $data in profiler ?
#1

[eluser]Flemming[/eluser]
It would be useful for me to be able to extend the profiler class so that it will display the contents of $data. I've had a poke around in the profiler but it doesn't seem to know what $data is. Can anyone suggest how I could achieve this?
#2

[eluser]Wittner[/eluser]
What do you mean by $data ?

are you talking about a situation similar to the following?:

Code:
$data['pageHeading'] = 'My home page';

... where you would like to see the value of $data echoed to the screen for debugging?
#3

[eluser]Flemming[/eluser]
exactly! I would like to always be able to see (when I have the profiler enabled) what $data contains, rather than have to echo it to the view whenever I want to see it
#4

[eluser]jedd[/eluser]
You could extend MY_Profiler.

Have a read of [url="http://ellislab.com/forums/viewthread/133671/"]this thread[/url] and grab n0xie's session-data-enabled MY_Profiler script - useful in itself, but also as an example for what you can do.
#5

[eluser]Flemming[/eluser]
Thanks for that Jedd - very useful! But I'm still none-the-wiser as to how to display the contents of $data! It's an undefined variable, so I tried $this->CI->data but that's an undefined property. As you can probably tell I'm stabbing around in the dark...
#6

[eluser]John_Betong[/eluser]
[quote author="flemming" date="1256930053"]Thanks for that Jedd - very useful! But I'm still none-the-wiser as to how to display the contents of $data! It's an undefined variable, so I tried $this->CI->data but that's an undefined property. As you can probably tell I'm stabbing around in the dark...[/quote]
 
http://ellislab.com/forums/viewthread/130302/#653952
 
Try fred(...) in the link above. Not only but also displays booleans, integers, floats, strings, arrays and objects - the answer to all your prayers?
 
 
 
edit: creating link instead of a string which occurs intermittently for some unknown reason? Also added a display for an object.
#7

[eluser]Flemming[/eluser]
thanks John - I'll take a look at that, sounds very promising! Smile
#8

[eluser]Flemming[/eluser]
John, this may be a very dumb question but how on earth does fred() know what I want it to process? In your example you pass in
Code:
$data='usage: fred("any type of data")', $data_name='missing_$data_name'
... how can I tell it I want it to use the CI $data array?
#9

[eluser]John_Betong[/eluser]
[quote author="flemming" date="1257194083"]John, this may be a very dumb question but how on earth does fred() know what I want it to process? In your example you pass in
Code:
$data='usage: fred("any type of data")', $data_name='missing_$data_name'
... how can I tell it I want it to use the CI $data array?[/quote]
 

Code:
// copy and paste this into your view  
  $boolean = TRUE;
  $num     = 123;
  $real    = 123.456;
  $str     = 'string value goes here';
  $a       = array('one', 'twow', 'three');
  $object  = 'works for objects as well';
  $curl    = 'under development';    

  fred($boolean, 'this is  boolean');
  fred($num,     'this is an integer');
  fred($real,    'this is a real number');
  fred($a,       'this is an array');
  fred($object,  'this is an object that displays the contents in an array');
  fred($curl,    'this is $curl properties');
 
 
The second parameter is optional but useful if you pass __FILE__ or __LINE, etc
 
 
 




Theme © iAndrew 2016 - Forum software by © MyBB