OpenWrt Luci Web Manager Add new menu (ii)

Source: Internet
Author: User
Tags lua

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.