Following previous: OpenWrt Luci Web Manager Add New menu
How to call:
In the/usr/lib/lua/luci/controller/admin/new_tab.lua file, add the following red section:
--Copyright Fulinux <[email protected]>
--Licensed to the public under the Apache License 2.0.
Local FS = require "Nixio.fs"
Module ("Luci.controller.admin.new_tab", Package.seeall)--notice that New_tab is the name of the file New_tab.lua
Function index ()
Entry ({"admin", "New_tab"}, FirstChild (), "new Tab"). Dependent=false--this adds the top Level tab and defaults to th E
Entry ({"admin", "New_tab", "TAB_FROM_CBI"}, CBI ("Admin_myapp/cbi_tab"), "CBI tab", 1)--this adds the first sub-tab that Is
Entry ({"admin", "New_tab", "Tab_from_view"}, Template ("Admin_myapp/view_tab"), "View Tab", 2)--this adds the second sub- Ta
entry ({"admin", "New_tab", "Action_counter"}, Call ("Counter"), _ ("Click here"), 3). Leaf = True
End
function counter ()
Local i = 0
If Fs.access ("/var/run/test") Then
i = Tonumber ((Fs.readfile ("/var/run/test")))
End
i = i + 1
Fs.writefile ("/var/run/test", String.Format ("%d\n", I))
--Luci.http.redirect (Luci.dispatcher.build_url ("Admin/new_tab/tab_from_view"))
Luci.http.write (ToString (i))
Return
End
Each time you click on the menu below, you will be redirected to a page showing the number of times you clicked on this menu:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
OpenWrt Luci Web Manager Add new menu (ii)