PHP class error

Permalink
I'm trying to use my own classes in my C5 site. Unfortunately I am unable to. They won't load in my template for some reason. I assume this is cause C5 won't allow it, because when i run them in a static page it works fine.

Is there something special I need to do to be able to use my own PHP objects with my C5 site?



Edit: To be a little more clear about whats happening... I'm loading in my class into the header of my C5 template with

require_once('/assets/inc/myclass.php');


And when I attempt to call it, I get the error
Call to a member function on a non-object

matthewmz
 
matthewmz replied on at Permalink Reply
matthewmz
Would I need to make my classes into controllers? Or extend them from the main C5 Controller?

This is stumping the heck out me.
Tony replied on at Permalink Reply
Tony
make sure you're using absolute paths on your includes. Concrete5 defined a global variable called DIR_BASE that'll be the system path to the root directory to your site. So if your concrete install has a class in the assets/inc/ directory, do this:

require_once(DIR_BASE.'/assets/inc/myclass.php');

if that doesn't work, echo out the path, and make sure it's right. forgot if that leading slash was necessary.
matthewmz replied on at Permalink Reply
matthewmz
Yeah I had absolutes originally, still didn't help. I don't know if its related, but it seems like my variables aren't carrying over from my theme includes either.

For example, I have a theme, and then I have a header file I include in it with the C5 function.

<?php $this->inc('elements/header.php'); ?>


But any variables I use in the header file won't carry over to my actual page type template.
matthewmz replied on at Permalink Reply
matthewmz
I used the model loader to load my classes, and they seem to load fine into the page. But not into each other. I have a database class I'm loading into a login class, but the global variable isn't working. But it works outside of C5.