{"id":275,"date":"2023-01-21T20:10:46","date_gmt":"2023-01-21T17:10:46","guid":{"rendered":"https:\/\/akaunting.com\/hc\/?post_type=docs&#038;p=275"},"modified":"2023-01-21T20:10:46","modified_gmt":"2023-01-21T17:10:46","slug":"settings","status":"publish","type":"docs","link":"https:\/\/akaunting.com\/hc\/docs\/developers\/settings\/","title":{"rendered":"Settings"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">We\u2019ve tried our best to ease the life of developers. Mostly, developers just want to add just some inputs on the settings page. In such a case, you can add them to the&nbsp;<code>module.json<\/code>&nbsp;file and Akaunting will display your module under the&nbsp;<strong>Settings<\/strong>&nbsp;page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">All you have to do is to fill the&nbsp;<code>settings<\/code>&nbsp;array like the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">\"settings\": [\n     {\n         \"type\": \"text\",\n         \"name\": \"header\",\n         \"title\": \"my-blog::general.header\",\n         \"icon\": \"fa fa-user\",\n         \"attributes\": {\n             \"required\": \"required\"\n         },\n         \"rules\": \"required|string\"\n     },\n     {\n         \"type\": \"radio\",\n         \"name\": \"enable_comments\",\n         \"title\": \"my-blog::general.enable_comments\",\n         \"enable\": \"general.yes\",\n         \"disable\": \"general.no\",\n         \"attributes\": {},\n         \"rules\": \"integer|boolean\"\n     },\n     {\n         \"type\": \"textarea\",\n         \"name\": \"meta_description\",\n         \"title\": \"my-blog::general.meta_description\",\n         \"attributes\": {},\n         \"rules\": \"nullable|string\"\n     }\n ]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Custom Settings<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If your settings page needs a little bit more action then you can listen to the&nbsp;<code>SettingShowing<\/code>&nbsp;event and create your own route, controller, and view files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a listener example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php\n\nnamespace Modules\\MyBlog\\Listeners;\n\nuse App\\Events\\Menu\\SettingsCreated as Event;\n\nclass AddToSettingsMenu\n{\n    public function handle(Event $event): void\n    {\n        $event->menu->route('my-blog.settings.edit', trans('my-blog::general.name'), [], 180, [\n            'icon' => 'edit',\n            'search_keywords' => trans('my-blog::general.description'),\n        ]);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can check the built-in Akaunting modules as live examples. The&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/akaunting\/module-offline-payments\" target=\"_blank\">Offline Payments<\/a>&nbsp;module ships with a custom settings page and the&nbsp;<a href=\"https:\/\/github.com\/akaunting\/module-my-blog\" target=\"_blank\" rel=\"noreferrer noopener\">My Blog<\/a>&nbsp;module uses the&nbsp;<code>module.json<\/code>&nbsp;file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019ve tried our best to ease the life of developers. Mostly, developers just want to add just some inputs on the settings page. In such a case, you can add them to the&nbsp;module.json&nbsp;file and Akaunting will display your module under the&nbsp;Settings&nbsp;page. All you have to do is to fill the&nbsp;settings&nbsp;array like the following: Custom Settings [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":31,"menu_order":5,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-275","docs","type-docs","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/comments?post=275"}],"version-history":[{"count":1,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/275\/revisions"}],"predecessor-version":[{"id":276,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/275\/revisions\/276"}],"up":[{"embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/docs\/31"}],"wp:attachment":[{"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/media?parent=275"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/akaunting.com\/hc\/wp-json\/wp\/v2\/doc_tag?post=275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}