Can this be done with ColdBox modules?

(CB newbie here...)

Say I have a page whose action is users.list, which does what it says.
Aross the top is a menu whose contents changes depending on your
location in the app and your user rights, and down the side is a box
with the latest 5 blog posts, the latest 5 tweets, and some ads. Those
same items appear on all the pages in this section of the app.

Each of those sideshow items could be thought built by the controller
calling different services to grab the relevant data, which the layout
then displays. You could use an interceptor or some other common hook
point to grab the model data on all pages that use that layout (I
think).

But that's not a very cohesive strategy. Really, I'd rather think of
each of those items as having its own mini-MVC cycle, where a
controller gets appropriate data from models and steers it to the
appropriate vars for a view to pick up. You could think about it as
MenuController, MenuService (model), and MenuView, and the same for
Blog, Tweets, and Ads.

These secondary MVCs aren't being used as the main action for a page
(that's something else), but as widgets that appear in different
locations and combinations on multiple pages. They might be the
central action on a different page, probably with different parameters
and views (the site's blog home page shows more posts in more detail,
for instance), but here they're part of the furniture surrounding the
main action. You should be able to reuse them with a single
parameterized call, rather than separate invocations of model and view
calls.

Can ColdBox modules be used like this? Are there docs and examples
somewhere? If not, and before there were modules, how did people
implement this kind of functionality?

Thanks.

No, they can't.

What you want to do is something like this.

Views
Views/handler
Views/handler/mainView.cfm
Views/pods/_subView.cfm

What this is doing is saying I will have a viewlet in my pods directory that
I can now place into any page or side navigation, then inside the viewlet
you will also be able to do something like this, depending on if you want to
use and announced interception or runEvent. I normally do the run event, as
I haven't had a chance to play with the announce side of things as yet.

<--- Execute Event --->
<cfset runEvent(event='viewlets.prepareViewlet1',private=true)>
<--- Or announce an interception --->
<cfset announceInterception('prepareMyViewlet')>

<--- Output Query --->
<cfoutput query="rc.MyQuery">
#currentrow#. #title#
</cfouput>

This is straight out of the docs for viewlets, thes removes the dependency
on any event and or core code. And if data is required for the viewlet that
is specific to the viewlet then this approach is what you are looking for.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of Dave Merrill
Sent: Tuesday, 14 September 2010 7:54 PM
To: ColdBox Platform
Subject: [coldbox:5779] Can this be done with ColdBox modules?

(CB newbie here...)

Say I have a page whose action is users.list, which does what it says.
Aross the top is a menu whose contents changes depending on your location
in the app and your user rights, and down the side is a box with the

latest 5

blog posts, the latest 5 tweets, and some ads. Those same items appear on
all the pages in this section of the app.

Each of those sideshow items could be thought built by the controller

calling

different services to grab the relevant data, which the layout then

displays.

You could use an interceptor or some other common hook point to grab the
model data on all pages that use that layout (I think).

But that's not a very cohesive strategy. Really, I'd rather think of each

of

those items as having its own mini-MVC cycle, where a controller gets
appropriate data from models and steers it to the appropriate vars for a

view

to pick up. You could think about it as MenuController, MenuService

(model),

and MenuView, and the same for Blog, Tweets, and Ads.

These secondary MVCs aren't being used as the main action for a page

(that's

something else), but as widgets that appear in different locations and
combinations on multiple pages. They might be the central action on a
different page, probably with different parameters and views (the site's

blog

home page shows more posts in more detail, for instance), but here they're
part of the furniture surrounding the main action. You should be able to
reuse them with a single parameterized call, rather than separate

invocations

Thanks Andrew, I haven't looked into viewlets yet, will do that. Seems
from what you've said like you'd want to build everything as viewlets,
from a cohesion and reusability point of view.

Dave

Yeah, I do that with things that I know is going to be on different type of
pages. A good example is a blog, where you have the opportunity to move the
viewlet from the side navigation to somewhere in the footer for example. Or
even have it not display in the view via a pod manager for example.

At least if it is removed from display by the user, you are not running code
that is never going to be displayed.

This is just a typical example, but the idea is promotion of code reuse,
with minimal work to get it moved around.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of enigment
Sent: Tuesday, 14 September 2010 8:18 PM
To: coldbox@googlegroups.com
Subject: Re: [coldbox:5781] Can this be done with ColdBox modules?

Thanks Andrew, I haven't looked into viewlets yet, will do that. Seems

from