<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/index.php?action=history&amp;feed=atom&amp;title=Writing_ACF_Controllers</id>
	<title>Writing ACF Controllers - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/index.php?action=history&amp;feed=atom&amp;title=Writing_ACF_Controllers"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Writing_ACF_Controllers&amp;action=history"/>
	<updated>2026-05-06T10:19:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Writing_ACF_Controllers&amp;diff=7012&amp;oldid=prev</id>
		<title>Dubiousjim: delete Category:HOWTO</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Writing_ACF_Controllers&amp;diff=7012&amp;oldid=prev"/>
		<updated>2012-03-21T16:04:58Z</updated>

		<summary type="html">&lt;p&gt;delete Category:HOWTO&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:04, 21 March 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l29&quot;&gt;Line 29:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 29:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;One of the more advanced features of a controller is redirection.  Using the &amp;#039;&amp;#039;redirect&amp;#039;&amp;#039; and &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039; functions of [[ACF_acf_www-controller.lua_reference | acf_www-controller]], the controller can cause the web browser to redirect to another page.  The &amp;#039;&amp;#039;redirect&amp;#039;&amp;#039; function causes a simple redirect to a different page.  This can be used, for example, to redirect to a listing page after successfully creating a new item using a form.  The &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039; function handles the redirection necessary for displaying forms as components and handling command actions.  These are described [[Writing_ACF_Views#Component_Forms | here]] and [[Writing_ACF_Views#Links_and_Commands | here]].  When implementing a form or command action, you should use &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;One of the more advanced features of a controller is redirection.  Using the &amp;#039;&amp;#039;redirect&amp;#039;&amp;#039; and &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039; functions of [[ACF_acf_www-controller.lua_reference | acf_www-controller]], the controller can cause the web browser to redirect to another page.  The &amp;#039;&amp;#039;redirect&amp;#039;&amp;#039; function causes a simple redirect to a different page.  This can be used, for example, to redirect to a listing page after successfully creating a new item using a form.  The &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039; function handles the redirection necessary for displaying forms as components and handling command actions.  These are described [[Writing_ACF_Views#Component_Forms | here]] and [[Writing_ACF_Views#Links_and_Commands | here]].  When implementing a form or command action, you should use &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:ACF&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]] [[Category:HOWTO&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:ACF]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dubiousjim</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Writing_ACF_Controllers&amp;diff=6811&amp;oldid=prev</id>
		<title>Dubiousjim: Categories</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Writing_ACF_Controllers&amp;diff=6811&amp;oldid=prev"/>
		<updated>2012-03-12T07:07:01Z</updated>

		<summary type="html">&lt;p&gt;Categories&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 07:07, 12 March 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l28&quot;&gt;Line 28:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 28:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Redirection =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Redirection =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;One of the more advanced features of a controller is redirection.  Using the &amp;#039;&amp;#039;redirect&amp;#039;&amp;#039; and &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039; functions of [[ACF_acf_www-controller.lua_reference | acf_www-controller]], the controller can cause the web browser to redirect to another page.  The &amp;#039;&amp;#039;redirect&amp;#039;&amp;#039; function causes a simple redirect to a different page.  This can be used, for example, to redirect to a listing page after successfully creating a new item using a form.  The &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039; function handles the redirection necessary for displaying forms as components and handling command actions.  These are described [[Writing_ACF_Views#Component_Forms | here]] and [[Writing_ACF_Views#Links_and_Commands | here]].  When implementing a form or command action, you should use &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;One of the more advanced features of a controller is redirection.  Using the &amp;#039;&amp;#039;redirect&amp;#039;&amp;#039; and &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039; functions of [[ACF_acf_www-controller.lua_reference | acf_www-controller]], the controller can cause the web browser to redirect to another page.  The &amp;#039;&amp;#039;redirect&amp;#039;&amp;#039; function causes a simple redirect to a different page.  This can be used, for example, to redirect to a listing page after successfully creating a new item using a form.  The &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039; function handles the redirection necessary for displaying forms as components and handling command actions.  These are described [[Writing_ACF_Views#Component_Forms | here]] and [[Writing_ACF_Views#Links_and_Commands | here]].  When implementing a form or command action, you should use &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:ACF]] [[Category:HOWTO]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dubiousjim</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Writing_ACF_Controllers&amp;diff=2363&amp;oldid=prev</id>
		<title>Ttrask: New page: A controller is an interface layer between the view and model.  The controller contains functions (actions) that make model functionality available to a user.  The actions interpret client...</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Writing_ACF_Controllers&amp;diff=2363&amp;oldid=prev"/>
		<updated>2008-07-09T18:19:50Z</updated>

		<summary type="html">&lt;p&gt;New page: A controller is an interface layer between the view and model.  The controller contains functions (actions) that make model functionality available to a user.  The actions interpret client...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A controller is an interface layer between the view and model.  The controller contains functions (actions) that make model functionality available to a user.  The actions interpret client data from the user, call model functions, and convert the model data for display by the view.&lt;br /&gt;
&lt;br /&gt;
= Controller Basics =&lt;br /&gt;
The basic function of the controller is to define what actions are available to the user.  There should be one action function for each thing that the user can do, and that function should only perform that one action.  The controller should not make any changes to the system, that&amp;#039;s the function of the model.  The controller should not be concerned with how to display data, that&amp;#039;s the function of the model.&lt;br /&gt;
&lt;br /&gt;
While there is usually a correspondance of one web page to one action, do not fall into the trap of thinking of an action as a web page generator.  The action should not be thought of as &amp;quot;a function to do everything necessary for this web page&amp;quot;, but rather &amp;quot;a function to perform a specific request&amp;quot;.  For example, an ACF designer may want a web page to display a list of files and a series of actions that may be done to those files.  Rather than creating an action that returns a list of files and accepts commands for what to do with them, create several actions - one to simply list the files and one for each action to be done to a file.  The view for the action that lists files should then generate links to each of the actions available for each file.  If you would like to add some status fields to that view, rather than adding status fields to the output of the action that lists files, create another action to return status and load it as a component of the view.&lt;br /&gt;
&lt;br /&gt;
= MVC Functions =&lt;br /&gt;
Each controller can define &amp;#039;&amp;#039;mvc&amp;#039;&amp;#039; functions that will be run when a controller is loaded/unloaded and before/after an action is called.  The most common usage is to create an &amp;#039;&amp;#039;mvc.on_load&amp;#039;&amp;#039; function to initialize variables and control access.  The controller might need to define an &amp;#039;&amp;#039;mvc.on_unload&amp;#039;&amp;#039; to free any resources loaded in &amp;#039;&amp;#039;mvc.on_load&amp;#039;&amp;#039;.  More information can be found in [[ACF_mvc.lua_example#mvc_load_.26_exec_special_functions | mvc.lua example]].&lt;br /&gt;
&lt;br /&gt;
= Default Action =&lt;br /&gt;
While there may be many actions defined within a controller, the controller should designate one action as the default.  If a user attempts to access a controller without specifying an action, the acf_www-controller will redirect them to the default action.&lt;br /&gt;
 default_action = &amp;quot;status&amp;quot;&lt;br /&gt;
&lt;br /&gt;
= Inputs =&lt;br /&gt;
When a controller is loaded by the mvc application, a table is created for the controller functions, model functions, and several other variables.  This table, known as &amp;#039;&amp;#039;self&amp;#039;&amp;#039;, is the only parameter passed to each action.  &amp;#039;&amp;#039;self&amp;#039;&amp;#039; also uses Lua metatables to allow the controller to access functions of acf_www-controller and mvc.  The controller should not access global variables defined outside of its scope.  The controller may load and use libraries.&lt;br /&gt;
&lt;br /&gt;
== self ==&lt;br /&gt;
The self table includes some entries that are of particular interest to controllers.&lt;br /&gt;
* self.clientdata - The client data.  Generally the information in POST or GET data from the web browser.&lt;br /&gt;
* self.conf - The configuration data, including information about the current user request, the application, and defined directories.&lt;br /&gt;
* self.sessiondata - The session data, containing information about user permissions, menu options, and command results.&lt;br /&gt;
* self.model - The model table containing references to all of the model functions.&lt;br /&gt;
&lt;br /&gt;
== libraries ==&lt;br /&gt;
The controller has access to many libraries defined in the system.  However, controller developers should be particularly interested in the &amp;#039;&amp;#039;controllerfunctions&amp;#039;&amp;#039; library.  This library is designed to be a helper library for controllers, handling common functionality.  If this library is used properly, most actions will only contain one line of code.&lt;br /&gt;
&lt;br /&gt;
= Redirection =&lt;br /&gt;
One of the more advanced features of a controller is redirection.  Using the &amp;#039;&amp;#039;redirect&amp;#039;&amp;#039; and &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039; functions of [[ACF_acf_www-controller.lua_reference | acf_www-controller]], the controller can cause the web browser to redirect to another page.  The &amp;#039;&amp;#039;redirect&amp;#039;&amp;#039; function causes a simple redirect to a different page.  This can be used, for example, to redirect to a listing page after successfully creating a new item using a form.  The &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039; function handles the redirection necessary for displaying forms as components and handling command actions.  These are described [[Writing_ACF_Views#Component_Forms | here]] and [[Writing_ACF_Views#Links_and_Commands | here]].  When implementing a form or command action, you should use &amp;#039;&amp;#039;redirect_to_referrer&amp;#039;&amp;#039;.&lt;/div&gt;</summary>
		<author><name>Ttrask</name></author>
	</entry>
</feed>