You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allows JViewHtml->getPath to set the extension of the layout file.
Allows for a different extension to be set for the layout
file. Adding a default extension to getPath easily allows the developer
to derive their own views with a new default.
Copy file name to clipboardExpand all lines: manual/en-US/chapters/packages/mvc.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -354,3 +354,38 @@ catch (RuntimeException $e)
354
354
// Handle database error.
355
355
}
356
356
```
357
+
358
+
The default extension for layouts is ".php". This can be modified in derived views by changing the default value for the extension argument. For example:
359
+
360
+
```php
361
+
/**
362
+
* My custom HTML view.
363
+
*
364
+
* @package Examples
365
+
* @since 12.1
366
+
*/
367
+
class MyHtmlView extends JViewHtml
368
+
{
369
+
/**
370
+
* Override the parent method to use the '.phtml' extension for layout files.
371
+
*
372
+
* @param string $layout The base name of the layout file (excluding extension).
373
+
* @param string $ext The extension of the layout file (default: "phtml").
374
+
*
375
+
* @return mixed The layout file name if found, false otherwise.
376
+
*
377
+
* @see JViewHtml::getPath
378
+
* @since 12.1
379
+
*/
380
+
public function getPath($layout, $ext = 'phtml')
381
+
{
382
+
return parent::getPath($layout, $ext);
383
+
}
384
+
}
385
+
```
386
+
387
+
##### Revision history
388
+
389
+
The new View package was added in 12.1.
390
+
391
+
The extension argument was added to `JViewHtml->getPath` in 12.3.
0 commit comments