From 215010386fd03c918e0c184fdec755b23b3f86cd Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 9 Feb 2024 13:23:59 -0500 Subject: [PATCH] Page::render() and PageRender::renderPage() documentation updates per processwire/processwire-requests#459 --- wire/core/Page.php | 2 +- wire/modules/PageRender.module | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/wire/core/Page.php b/wire/core/Page.php index 9d90ab3d..a5a3c68c 100644 --- a/wire/core/Page.php +++ b/wire/core/Page.php @@ -105,7 +105,7 @@ * * Methods added by PageRender.module: * ----------------------------------- - * @method string|mixed render($fieldName = '') Returns rendered page markup. If given a $fieldName argument, it behaves same as the renderField() method. #pw-group-output-rendering + * @method string|mixed render($arg1 = null, $arg2 = null) Returns rendered page markup. Please see the `PageRender::renderPage()` method for arguments and usage details. #pw-group-output-rendering * * Methods added by PagePermissions.module: * ---------------------------------------- diff --git a/wire/modules/PageRender.module b/wire/modules/PageRender.module index 77bf0e80..1e1e4c04 100644 --- a/wire/modules/PageRender.module +++ b/wire/modules/PageRender.module @@ -382,13 +382,20 @@ class PageRender extends WireData implements Module, ConfigurableModule { } /** - * Return a string with the rendered output of this Page from its template file + * Return a string with the rendered output of this Page from its template file (other usages available as well) * * This method provides the implementation for `$page->render()` and you sould only call this method as `render()` from Page objects. - * You may optionally specify 1-2 arguments to the method. The first argument may be an array of options OR filename (string) to render. - * If specifying a filename in the first argument, you can optionally specify the $options array as the 2nd argument. - * If using the options argument, you may specify your own variables to pass along to your template file, and those values will be - * available in a variable named `$options` within the scope of the template file (see examples below). + * + * You may optionally specify 1-2 arguments to the method. The first argument may be any of the following: + * + * 1. An $options array with predefined options or custom variables (see available options further below). + * 2. A filename to use for render (in /site/templates/). When used, you can optionally specify the $options array as the 2nd argument. + * 3. A field name to render. An optional 2nd argument can be a filename (in /site/templates/fields/) to use to render the field. + * Please see the `Page::renderField()` method for more details for this usage (you may want to use that method instead). + * + * If using the $options array argument (whether 1st or 2nd argument), you may use it to specify your own variables to pass along to your + * template file, and those values will be available in a variable named `$options` within the scope of the template file + * (see examples below). * * In addition, the following options are present and recognized by the core: * @@ -401,7 +408,7 @@ class PageRender extends WireData implements Module, ConfigurableModule { * - `appendFiles` (array): Array of additional filenames to append to output, must be relative to /site/templates/. * - `pageStack` (array): An array of pages, when recursively rendering. Used internally. You can examine it but not change it. * - * Note that the prepend and append options above have default values that come values configured in `$config` or the Template object. + * Note that the prepend and append options above have default values that have defaults configured in `$config` or the Template object. * * ~~~~~ * // regular page render call