2008/11/2 Mark Mandel <[EMAIL PROTECTED]> > > Nothing too fancy, in the book decorator - > > (Really light code, cause I'm tying in a email box) > > <cffunction name="hasTheme" return="boolean"> > <cfargument name="theme" /> > <cfset var themes = getThemeArray() /> > <cfset var theme = 0 /> > <cfloop array="#themes#" index="theme"> > <cfif theme.getParentTheme().transferEquals(arguments.theme)> > <cfreturn true /> > </cfif> > </cfloop> > <cfreturn false/> > </cffunction> > > You should be able to work out the 'getTheme' from there. >
ahh.... very nice! Thank you . Just implemented this... I've changed some relationship names because booktheme and theme were getting muddled with me foolishly having called my onetomany relationship (book to booktheme) "Theme". The booktheme relationship is now called "StarRating" as each theme associated with a book has a star rating. My decorators became has/get/deleteThemeStarRating I ended up with : <cffunction name="hasThemeStarRating" return="boolean"> <cfargument name="theme" /> <cfset var aStarRating = getStarRatingArray() /> <cfset var thisStarRating = 0 /> <cfloop array="#aStarRating#" index="thisStarRating"> <cfif thisStarRating.getParentTheme().equalsTransfer(arguments.theme)> <cfreturn true /> </cfif> </cfloop> <cfreturn false/> </cffunction> NOTE : Mark said transferEquals, but its actually equalsTransfer (threw me for a short time there) ;) I've managed to reduce my main code by about 50% because of this and the readability is substantially greater too. Thanks again Mark. Regards Stephen --~--~---------~--~----~------------~-------~--~----~ Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer You received this message because you are subscribed to the Google Groups "transfer-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/transfer-dev?hl=en -~----------~----~----~----~------~----~------~--~---
