Views

Structure your view directory in either (or both) of these approaches:

Same name resources

public/ ... public files
view/
- Blog.php
- Blog.js
- Blog.css

Nested resources

public/ ... public files
view/
- Theme.php
- Theme/
    - anyName.js
    - anyName.css

Notes

  • Calling $view = $lia->view('Theme', $args) will encompass Theme.php and load every single .js and .css file in the Theme directory
  • Calling $view = $lia->view('Blog', $args) will encompass Blog.php for the view and load Blog.js and Blog.css
  • $args are extracted so your Theme.php & Blog.php files receive the array keys as paramaters.
  • Resource files are loaded when you call $view->resources(), $content = $view->content(), or $content = "".$view; (tostring)
  • Place your view in a subdirectory like view/Theme/Light.php for a view named Theme/Light

TODO

  • Namespacing. Views gotta have namespaces
  • Do nesting views load too many resources? Ex: view/Theme/Light.[php|css|js] $lia->view('Theme'). Does it include Light.[css|js]? It shouldn't, but I think it does.

Overriding Views

By order of Package addition

$liaison = new \Liaison();
$lia->setViewConflictMode('overwrite');
//$starter contains a view named 'theme'
$starter = new \Lia\Package($liaison, $starterDir);
// $mySite also contains a view named 'theme'
$mySite = new \Lia\Package($liaison, $mySiteDir);

$mySite's theme view will be displayed when $lia->view('theme') is called

By explicit function call

$lia->setViewConflictMode('overwrite');
$lia->addView('\\Lia\\Obj\\View', $viewDir, $viewName);