CFWheels Controller/Action Base File Creator


/ Published in: ColdFusion
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <!---
  2. CFWheels Controller/Action Base File Creator
  3.  
  4. 1) Set variable "outputFolderPath" to your "output" folder
  5. 2) Set variable "controllers" by starting a new controller with @
  6. and then the list of actions.
  7. EX:
  8. @ControllerOne,index,add,edit,delete
  9. @ControllerTwo,index,report
  10. @ControllerThree,action1
  11. --->
  12.  
  13. <!--- User Defined Variables --->
  14. <cfset outputFolderPath = "C:\wwwroot\">
  15. <cfset controllers = "@Home,Index,Search
  16. @StudentProfile,Index,ViewFinalSubmissionDetails,SendMsgToStudent
  17. @Communications,Index,ViewSingleCommunication
  18. @Admin,Index,Programs,Deadlines,FCLA_Transfers,SiteContent,IndexProcess,ProgramsProcess,DeadlinesProcess,FCLA_TransfersProcess,SiteContentProcess
  19. @Templates,Index,Add,Edit,Delete,IndexProcess,AddProcess,EditProcess,DeleteProcess
  20. @Reports,Index">
  21.  
  22. <!--- Loop thru controller "packages" (Controller+Actions)--->
  23. <cfloop list="#controllers#" delimiters="@" index="oneSet">
  24. <cfset counter = 0>
  25. <cfset finalOutput = "<cfcomponent extends=""Controller"">
  26. <cffunction name=""init"">
  27. <!--- Code --->
  28. </cffunction>">
  29. <!--- Loop thru actions of one controller--->
  30. <cfloop list="#oneSet#" delimiters="," index="oneSetDetails" >
  31. <cfif counter eq 0>
  32. <cfset fileName = trim(oneSetDetails)&".cfm">
  33. <cfoutput><h1>Controller: #fileName#</h1></cfoutput>
  34. <cfelse>
  35. <cfset finalOutput &= "
  36. <cffunction name="""&trim(oneSetDetails)&""">
  37. <!--- Code --->
  38. </cffunction>">
  39. <cfoutput><h2>Action: #oneSetDetails#</h2></cfoutput>
  40. </cfif>
  41. <cfset counter++>
  42. </cfloop>
  43. <cfset finalOutput &= "
  44. </cfcomponent>">
  45. <hr/>
  46. <cfset filePath = outputFolderPath & fileName>
  47. <cffile action="write" file="#filePath#" output="#finalOutput#">
  48. </cfloop>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.