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 encompassTheme.php
and load every single.js
and.css
file in theTheme
directory - Calling
$view = $lia->view('Blog', $args)
will encompassBlog.php
for the view and loadBlog.js
andBlog.css
-
$args
areextract
ed so yourTheme.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 namedTheme/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 includeLight.[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);