admin-page-framework; interpret array

LPH

Well-known member
My education continues .... ;)

I built a checkbox option within a settings page. The option "0" and "1" work because I can put the following to see the changes when the form is saved via a submit button. (Yeah!).

PHP:
echo $this->0Debug->getArray( $this->oProps->arrOptions );

Works great and returns

Code:
Array {
[xf_branding] => Array {
     [branding] => Array {
          [checkbox] => 0 
          }
     }
}

The zero will change to a 1 when the box is checked.

Now, looking at the array, I want to build an if statement wrapped around a echo "This is showing when unchecked...."

PHP:
function footer() {
     if ( ????????? == '0' ) {
              echo "This is showing when unchecked";
    }
}

Now, I'm still struggling with an array and a key. I've tried different options in the ?????? location. Does someone (1) have any idea immediately how to fix this so the conditional works .. (2) more importantly, is there a good reference or tutorial on arrays?

Ever so appreciated.
 
PHP:
function footer() {

     if ($this->oProps->arrOptions['xf_branding']['branding']['checkbox']== '0' ) {
              echo "This is showing when unchecked";
    }
}
 
So, in this case, the arrays are joined simply with the square brackets, right?

Now this is inside the class "XFAdmin" ...
 
Oh .. Holy Crap .. I was spelling checkbbox and not checkbox ...

Works like a charm. Thank you.
 
Ugh. I posted "Works like a charm." a bit too early.

Yes, this works within the class. Pulling the conditional outside of the class leads to the $this is poop code. OK. It actually says:

Code:
Fatal error: Using $this when not in object context in ..." blah blah duh.

OK. Back to scouring the web and trying to read up on procedural versus OOP. :(
 
OK. Found a few good references, besides here, Google key terms, and stackoverflow. Learnable has a few good videos and ebooks. Killerphp.com was good to fill in some knowledge gaps (skimming versus reading can cause an issue ...).

My main challenge right now is not understanding calling static variables defined in a class in a function not in the class. The fact I can now define this as my challenge is probably 90% of finding the solution ;) Anyway, I see global is used in many scripts but this seems to fail in my attempts. I also would prefer a cleaner way than calling global all the time.

In the meantime, I'm giving up on admin-page-framework as a plugin tool for building admin pages. It was fast for building the pages but getting the variables out has been too cumbersome. I'll return to figuring out how to build the admin pages using my own classes. This will take longer but might be more advantageous as time goes.

The good news is that I built a quick custom post type - and am trying to figure out how to expand the columns in WordPress all post to show the thread_id ... this should be a cool addition for WP users :)
 
Back
Top Bottom