Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation addendum for api-vars access #526

Open
pine3ree opened this issue Jun 16, 2024 · 0 comments
Open

Documentation addendum for api-vars access #526

pine3ree opened this issue Jun 16, 2024 · 0 comments

Comments

@pine3ree
Copy link

Access api vars from templates using $this->{api-var-name}

Inside pw template files and all partials included using wireRenderFile($template, $vars) aka $files->render($template, $vars) $this refers to the TemplateFile instance, so we can access api-vars in the following way:

<?php namespace ProcessWire;

// Next line add autocompletion for $this
/** @var TemplateFile $this */

$this->page;
$this->files->render('view/layout.html.php', get_defined_vars());
// etc...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant