viewCollection.getView() inside a view

23 views
Skip to first unread message

John C. Bland II

unread,
Oct 8, 2009, 1:39:36 PM10/8/09
to model...@googlegroups.com
Ok, I have templates which has a getView(...) and inside of the view is another getView(...).

Here's why:
[template]
  body
    {global stuff here}
    getView("panel")
  /body

[dashboard/panel]
div id="left"
getView("quicksearch")
getView("messagecenter")
/div

[home/panel]
div id="right"
getView("login")
getView("ad")
/div

So...the template includes the panel flat out. The config details which panel to include and each panel could use some of the same code from another panel.

Now...the internal views (login, ad, search, etc) could get custom tags (which I'm considering) but this issue came up and I don't like not knowing why something fails.

Thoughts?

---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"

John C. Bland II

unread,
Oct 9, 2009, 2:47:40 PM10/9/09
to model...@googlegroups.com
bump

---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"


Dan Wilson

unread,
Oct 9, 2009, 2:59:45 PM10/9/09
to model...@googlegroups.com
Sorry John, I really don't understand the question. Maybe more/better code snippets are in order?

Might I suggest using http://modelglue.pastebin.com 


DW
--
“Come to the edge, he said. They said: We are afraid. Come to the edge, he said. They came. He pushed them and they flew.”

Guillaume Apollinaire quotes

John C. Bland II

unread,
Oct 9, 2009, 4:07:07 PM10/9/09
to model...@googlegroups.com
http://modelglue.pastebin.com/d22e2ca16

The template has the getView and the panel (passed in from MG config) has another getView. If I don't use the panel and put the code in the body.cfm, it works just fine. With the code in the panel it fails.

Is there a path issue when you get inside included templates? It reminds me of includes in includes in includes with normal CF (where the path isn't site root).

Event Type:
        <event-type name="Global">
            <after>
                <views>
                    <include name="globalnav" template="global/globalnav.cfm"/>
                    <include name="utilities" template="global/utilities.cfm"/>
                    <include name="navsearch" template="global/navsearch.cfm"/>
                    <include name="quicksearch" template="global/quicksearch.cfm"/>
                    <include name="messagecenter" template="global/messagecenter.cfm"/>
                    <include name="footer" template="global/footer.cfm"/>
                </views>
            </after>
        </event-type>

Handler:
        <event-handler name="dashboard" type="Global,SecurePage,InteriorTemplate">
            <views>
                <include name="body" template="/pages/dashboard/body.cfm"/>
                <include name="panel" template="/pages/dashboard/panel.cfm"/>
            </views>
        </event-handler>


---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"


Dan Wilson

unread,
Oct 9, 2009, 4:14:18 PM10/9/09
to model...@googlegroups.com
I think you misunderstand the order of operations.

Your event handler has a body and a panel. When the event is fired, both of these are queued for processing.

Then, the EventType stuff kicks in (because you used the <after> rule) and the messagecenter and quicksearch and other views are queued for processing.

Lastly, the view queue gets rendered in order, so that means body, then panel, then globalnav, then utilities, then navsearch, then quicksearch, then the footer.

So, when the panel is rendered, all that is in the rendered view collection is the body. Thus, when you ask for views that haven't been manufactured yet, you get an empty string. Hence your problem.


DW

John C. Bland II

unread,
Oct 9, 2009, 4:17:47 PM10/9/09
to model...@googlegroups.com
DOH! Changed the after to before and it works. That's what I get for copy/paste then tweak. :-D


---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"


Dan Wilson

unread,
Oct 9, 2009, 4:24:39 PM10/9/09
to model...@googlegroups.com
Right, well that makes sense. Though depending on what you are doing, you may not find <before> to be the best templating use. If you run into Chicken vs Egg issues, feel free to use both <before> and <after> blocks to get the right mix.

Aren't you in LA John?  I'm doing a free day of training tomorrow if you are going to be around. If you have an interest, let me know and I'll check on where we are on capacity.


DW

John C. Bland II

unread,
Oct 9, 2009, 4:26:30 PM10/9/09
to model...@googlegroups.com
Point taken.

I wish I were. I'm in Houston.

Sent from iPhone 3G

Dan Wilson

unread,
Oct 9, 2009, 4:29:20 PM10/9/09
to model...@googlegroups.com
Heh. I-10 is a long straight road. 

Just think, if you left now, you'd get there in time to miss the class. :)

I'm doing another free day of training in Bloomington, IL for BFusion (http://bflex.info/) It is over the weekend and should be a fun time!

If you can't make that one, maybe we could set something up for Houston at some point.


DW

John C. Bland II

unread,
Oct 9, 2009, 4:57:00 PM10/9/09
to model...@googlegroups.com
Yeah, long is right. lol. I used to live in Phoenix so that TX stretch is a beast. :-)

Coo on IL and sweet on Houston. That'd be GREAT!


---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"


Reply all
Reply to author
Forward
0 new messages