Jump to content

Am I doing something wrong?


Utherr12
 Share

Recommended Posts

	function _get_template_list() {		if (empty($this->template_list)) {			$dir = new DirectoryIterator(DOKU_INC.'tpl/');			$tpl_list = array();						foreach($dir as $file) {				if($file->isDir() && !$file->isDot()) 					$tpl_list[] = $file;			}			$this->template_list = $tpl_list;		}		else return null;	}

I don't think the whole class matters. If I comment out the line where I call this method inside another method of the same class, the page works, otherwise I'm getting 500 Error.I just want to know if my method is my mistake or there's something more to it.DOKU_INC is a constant to a path, I've checked it and it's good.

Edited by KingA
Link to comment
Share on other sites

Does DOKU_INC end with a "/"? If not, the whole string will lead to a non-existent path, therefore throwing an exception, therefore leading to the error.Also, notice that in both cases the function would return null, because after the loop, you aren't returning anything (therefore the default return value null). Is that what your outer layer expects, or should the templace list itself be returned?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...