[Solar-talk] Solar_View - ability to have default $_template_file

Matt M. goodieboy at gmail.com
Sun Oct 15 14:01:32 PDT 2006


Hi, not sure how to "reply" to this list yet! I'm getting the daily digest,
which may be a problem. I'll change my account settings. Anyway, I'm just
going to re-post some text here...

> I've noticed that the view class does not hold on the the template
> path value. Everytime you render you have to tell it which template to
> use, which means you can't pass it around to other objects and render
> without the other objects knowing which template to use. I have a
> controller framework that allows child controllers to pass their
> responses (Solar_View) to their parent, but then the parent needs to
> know what template to use... which does not work.
>
> ... snip ...

And from Travis....
I'd be curious to see an actual use case for this.  Maybe seeing it
outside of your controller is what is making it hard for me to see what
it's purpose is.  Could you post up simple use case if for no other
benefit than mine?

-Travis


Travis,

What I'm doing is having a controller prepare a view. The view is a response
object. The response has properties and knows how to render itself. That's
where it gets weird for me. The view returned by the controller should be
able to know what template should be used or the "client" code needs to
figure it out. I could just pass the view back as a string, but there are
values inside of the view instance that can be re-used and merged into
parent views (for example) that are useful; like a page title, or a
collection etc.. Here is an example:

function getPage(){
  $view = Solar::factory('Solar_View');
  $view->title = 'Contact Us';
  return $view->fetch('contact.php');
}

// $page is now a string
$page = getPage();

$layout = Solar::factory('Solar_View');
// can't do this because the $page is a string - and $layout could get it's
title from this:
// $layout->assign($page);
// the following line could/would be: $layout->content = $page->render();
after setting $page->setTemplate('contact.php')
$layout->content = $page;
$layout->display('main.php');

If I could just throw the assign function another view object, the $layout
would be able to use all of it's properties. My idea is to allow a default
template file value by passing it into the $config or adding a method called
setTemplate($file)

Is this making sense? I've been coding for 3 days straight, so it might
not!!! :)

- Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.killersoft.com/pipermail/solar-talk/attachments/20061015/bc0ed093/attachment.htm 


More information about the solar-talk mailing list