The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

views looking messy, is there a better way?

I choose the concat method, however, it's hard on the eyes: I didn't notice until i worked with a non programmer. [designer]

PHP Code:

$this->html.='<p class="more">'.
'<a href="/rss" title="Click here to see an XML representation of the content of this weblog."><img src="'.EnumArticleConstants::$path.'themes/'.$this->theme.'/img/xml-summaries.gif" alt="Click here to see an XML representation of the content of this weblog." /></a> '.
'</p>';

I took a look at smarty template engine, however i never implemented it as I felt the learning curve for the designer would be as much as picking up basic semantics for php. (also php has incredible documentation and is easy to learn)

so I tried to recreate the crash course in php.. I'll like to get feedback on this if possible ...its attached. [i'll like to take a look at some advanced smarty template files to c if i can recreate them using what i've created]

I used a registry to register my transfer object in case the data access and view were not sequential. meaning data access was called a lot earlier than the view. This has a negative effect in that i can't reuse templates since the view asks the registery for a specific transfer object. [example 1]

are data access and view ever that seperated?

Example 2 shows a template the doesn't explicitely request the transfer object.. but expects for the object to exist in the same scope. [require instead of require_once]

2
How many use the method described on page 282 of harry's volume 2 book? Does anyone know what this method is called? dao? ..as it does create a transfer object.

3
i plan to refactor a lot of my views this summer as i feel the views have become bloated. Take a look at my biggest view. How can i redesign using view helpers?
- one of my ideas in refactoring is to implement view helpers as described in core j2ee patterns by alur..
anyone with any advice?

4
lastly does anyone use composite controllers?
are composite controllers the same as chain of responsiblity
my thoughts are to have all my applications have a controller.. and in the __constructors add specific controllers for that domain.
CalendarController, AuthenticationController, ArticleController

this might be helpful in answering some of my questions

attached is the screen shot of the view [note i cut some of the article]

in previous applications all files have standard place to be included. Either constants.php or the application specific constants.php
I always felt more control instead of including files randomly in the view .. what do ya feel about includes randomly spread throughout the app?

phpsmarty design
the user can map data to values he wants... uses __get intercept
uses final on construct so user cannot overload and affect the logic.
user must implement the routine in map.

>Dr Livingston
i'll do my searching this week.. i've already found some gems about composites/composite views. I guess i'll concentrate on CoR since composites +visitors are becomming more and more familiar ground.

In this composite view, all views now need logic inside to decide how exactly the view should be represented. Example login.tpl.phtml: when a user has logged in; the view should change to show the user name instead of the login form.

$ViewBuilder = CompositeViewFactory::getInstance($RequestObject); //returns the full composite tree for a defined view
$ViewBuilder->render(); //each component in the tree will have to fetch its own data

is there any application that takes advantage of both the composite view and the composite controller? I feel that they approach page generation with different strategies that collide with one another if implemented together on 1 site.

Not really - If the class has logic, that is concerned with the request, then it's most likely doing controller logic. So that would make it a composite controller.
My conclusions so far is that composite (hierachial) controllers are a good design, whereas adding a composite view structure to this is overkill. Composite views in them selves (with a single controller) is just not flexible anough. If your application is complex enough to need composite view, it probably needs composite controllers aswell.

Originally Posted by leblanc

just wanted to put the block of code that manages all my components in index.php. i guess you would call this the page controller?

Page controller and front controller are patterns for how the http-request is translated into execution of code. It doesn't have anything to do with the internal processing. Exactly where the boundry between request-translation and internal flow is drawn is tricky though. In reality no clear distinction can be made. In general however, page controller refers to an architecture where you have multiple scripts with the .php extension. A front controller in contrast, is an architecture where you have just one .php script, which then dispacthes to a handler. This handler contains the same code as the page controller would - in fact it may be completely identical. The difference is in which way it is invoked - not in what it contains/does.

You can normally identify if a site uses page or front controller by looking at it's url's :forum.php?thread=22 --> Page controllerindex.php?c=forum&thread=22 --> Front controller

Often the front controller is used together with mod_rewrite, to give "pretty urls". So this would mean that in reality the front controller might have url's like this :/forum/22

okay.. one more time

Sorry to continue this thread. I work alone therefore i rely on forums/books to keep me in touch with what others are doing in similar circumstances. Everyone's input is deeply appreciated.

My original goal was to design my code so a designer and programmer roles are seperated. Also, I wanted to create something more efficient/scalable than my current method to generate the page. I also wanted to design components so they can be used in other projects without a hassle.

Although the composite view would solve my page generation problem, it will entangle the programmer/designer roles. Therefore i don't think this is a good choice.

The problem with the current composite controller is that it does not describe the details on how the page is actually generated using the composites. Can it really handle complex views with this?

>lvismer
How do you imagine the final render of the page?

header txt
body txt
faq txt
calendar txt
article txt
footer txt

????

from what i see, the final render of the page would be directly related to how items were attached.

In real life however most pages are not designed like this. The composite controller structure cannot/should not tie down the final page render.

in real pages you have regions.

A regions is similar to a box model. A box that can contain a list of recently posted article titles, a list of upcomming events, and a list of recent uploaded pictures.

In another region you could have a full txt article with a listing of faq's the correlate to the article.

[this region requires article and faq components/modules]

[see the view i posted previously for a real page]

I created the following image so everyone can understand what i mean about regions.

I have given this a lot of thought. Here is a sequence diagram that hopefully describes what my next plan is. Basically give the responsibility to regions. How do you know which region you need for a page request.. that responsibility is put on the page builder which requires page resolver.

thoughts anyone?

i currently have this simple version working. basically articlecontroller sets static data in the region which is then requested by the pagebuilder. It's very simple version since the articlecontroller isn't resolving any commands...but only sending static data back. The sequence diagram here describes in essense what i currently have working.

using the page frame resolver i also eliminate conditionals in my page class and seperate my code from designer code.