Jump to content

Getting all children template filenames without path


Recommended Posts

Posted

For onpager navigation I'm trying to get the name of all template php files so I can include them based on their status (hidden/shown). But I cannot get the names without the path. So

foreach($page->children() as $child) {
	echo $child->template->filename()."<br/>";
}

gives me the whole path for each file. In https://processwire.com/api/ref/template/filename/# it is stated, that the argument $filename can omit the path, but without examples I'm to dumb to find out how to use it...

PS: of course I could strip it with vanilla php, but if there is already a function for that I'd rather use it.

Posted

basename($child->template->filename) does the job of course, thanks.

But I still do not understand how the function in Processwire is used.  The reference is not very clear.

  • Confused 1

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...