I'm in the process of moving an older CF app into CB. One thing I'm
trying to come up with a solution for is taking a lot of the
conditional logic out of the views.
For Example, there are views where there are several <cfif> statements
that just show different images or different styles based on the
current page.
What I have decided to do is break these into different views, name
them based on the event they will be shown in and then use renderView
().
So if my current event is "main.index" I will name the menu view
something like "vwMain.index.cfm" and then call #renderView('/shared/
menu/vw' & event.getCurrentEvent())#
The old menu system I have right now looks something like:
<cfif SCRIPT_NAME eq "myscript.cfm">
<td class="menu_off_usermenu">
<a href="someotherscript.cfm" class="menubarlink" style="text-
decoration: none;"><img src="/includes/images/layout_edit.png"
border="0" alt=""> New</a>
</td>
<cfelseif SCRIPT_NAME contains "myscript2">
<td class="menu_on_usermenu">
<a class="menubarlinkon" style="text-decoration: none;"><img src="/
includes/images/layout_edit.png" border="0" alt=""> New</a>
</td>
<cfelse>
<td class="menu_off_usermenu">
<font class="link_off"><img src="/includes/images/layout_edit.png"
border="0" alt=""> New List</font>
</td>
</cfif>
I just wanted to see if anyone might think there is a better approach.
I'm really trying to make the application easier to make changes and
for some of these views that use this type of conditional logic, this
seemed to make sense.
I welcome any better suggestions.
Thanks,
Ben