Using classes in nodes I need a little bit of guidance, I made a custom class and im trying to use it in a node but of course it throwing a white screen at me. So my question is how can I go about using a custom class for d7 so I can include the tag in my node via php.

I put this code in the template.tpl.php file and tried using it in my node but it then gave the white screen.

&lt;?php class Colors {

  public function red_form() {
        echo 'color red is here';
  }

    public function blue_form() {
        echo 'color blue is here';
  }

    public function green_form() {
        echo 'color green is here';
  }

    public function purple_form() {
        echo 'color purple is here';
  }

    public function yellow_form() {
        echo 'color yellow is here';
  }
}

$colorforms = new Colors();

?&gt;


and im using this in the node.

Text here here and here.

&lt;?php $colorforms-&gt;red_form(); ?&gt;

More text here here and here.


the output im trying to get using the code above is.

Text here here and here.

color red is here

More text here here and here


is there a module or something for this? or anything to that nature, im a little in the dark on this.
Quick fix: declare the class in template.php but instantiate it in your node template (if you check your php error log you probably had something like "Call to a member function red_form() on a non-object in ..." in it).  Also, I am assuming it's a typo that you had $colorforms and $color_form in your example above.