[luci] Custom buttons and functions

Loren Stafford lstafford at ubicom.com
Fri Sep 25 01:33:45 CEST 2009


I’m no expert, but I’ll share what I learned recently.

You want to use LuCI templates (http://luci.freifunk-halle.net/Documentation/Templates) not CBI models. You have to write most of the core HTML (minus the header and footer), but you can use HTML as you are accustomed, yet with full access to LuCI thru Lua. 

Your page mytemplate.htm will look like:

<%+header%>
<%
require "luci.http"
require "luci.sys"
require "luci.fs"
-- Most of your lua code
%>
<!-- 
	All your HTML (and Javascript) code with embedded LuCI markup <% .. %>. 
	Copy HTML/CSS classes from existing LuCI pages to get similar formatting. 
-->
<%+footer%>

The page will reside at applications/myapp/luasrc/view/mymod/mytemplate.htm

In the controller you will have an entry such as:

        entry({"admin", "myapp", "mytemplate"}, template("mymod/mytemplate.htm"), "Template Title", 10).dependent=false

Look at existing templates for models. You can find them by searching all controllers for 'template('.

That is about all there is!  8-)

-- Loren 
 



More information about the luci mailing list