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
And when I attempt to call it, I get the error
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
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.
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.
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.
But any variables I use in the header file won't carry over to my actual page type template.
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.
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.
This is stumping the heck out me.