Jump to content

How to pass all API variables to $files->render() ?


Recommended Posts

I'm working on a new markup module and want to have the API available in the included file. I know I can do that:

$code = $this->files->render('myfile', [
  'page' => $this->page,
  'pages' => $this->pages,

Then I'd have $page and $pages in my file, but I'd need to list all available API variables manually and keep them in sync with the API.

Other solution:

$code = $this->files->render('myfile', [
  'that' => $this,

Then I'd have all API variables available from $that->page, $that->pages etc.

Can I get best of both? Thx ? 

Link to comment
Share on other sites

1 hour ago, Markus (Blue Tomato) said:

Use wire('all')

Awesome! Exactly what I was looking for, thx ? Maybe also interesting for you @kongondo (or are you already using it like this in your module?)

Thx for the idea @ukyo but I need that feature for backend development and I can't rely on the functions API and it's also only recommended for use on the frontend.

Link to comment
Share on other sites

  • 2 weeks later...
On 7/21/2019 at 6:41 AM, Robin S said:

Please note that all template files automatically receive all API variables already (you don't have to provide them).

Thx Robin ? Didn't know that, just tried it and it also works for $files->include() ?

  • Like 1
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

  • Recently Browsing   0 members

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