/ Published in: ColdFusion
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!--- CFWheels Controller/Action Base File Creator 1) Set variable "outputFolderPath" to your "output" folder 2) Set variable "controllers" by starting a new controller with @ and then the list of actions. EX: @ControllerOne,index,add,edit,delete @ControllerTwo,index,report @ControllerThree,action1 ---> <!--- User Defined Variables ---> <cfset outputFolderPath = "C:\wwwroot\"> <cfset controllers = "@Home,Index,Search @StudentProfile,Index,ViewFinalSubmissionDetails,SendMsgToStudent @Communications,Index,ViewSingleCommunication @Admin,Index,Programs,Deadlines,FCLA_Transfers,SiteContent,IndexProcess,ProgramsProcess,DeadlinesProcess,FCLA_TransfersProcess,SiteContentProcess @Templates,Index,Add,Edit,Delete,IndexProcess,AddProcess,EditProcess,DeleteProcess @Reports,Index"> <!--- Loop thru controller "packages" (Controller+Actions)---> <cfloop list="#controllers#" delimiters="@" index="oneSet"> <cfset counter = 0> <cfset finalOutput = "<cfcomponent extends=""Controller""> <cffunction name=""init""> <!--- Code ---> </cffunction>"> <!--- Loop thru actions of one controller---> <cfloop list="#oneSet#" delimiters="," index="oneSetDetails" > <cfif counter eq 0> <cfset fileName = trim(oneSetDetails)&".cfm"> <cfelse> <cfset finalOutput &= " <cffunction name="""&trim(oneSetDetails)&"""> <!--- Code ---> </cffunction>"> </cfif> <cfset counter++> </cfloop> <cfset finalOutput &= " </cfcomponent>"> <hr/> <cfset filePath = outputFolderPath & fileName> <cffile action="write" file="#filePath#" output="#finalOutput#"> </cfloop>