Problem with Administration Settings app

Hello,
I wanted to create an App that is located in the Administration Settings.
I have followed these two Tutorials:
https://docs.nextcloud.com/server/latest/developer_manual//basics/setting.html?
https://docs.nextcloud.com/server/latest/developer_manual/basics/setting.html

But none of them work!

After I enable the App and i want to reach the settings page, there is an internal Server Error.

Can somebody help please, or does somebody know any other tutorials that work?

This would be my code for the Admin Settings:

<?php
namespace OCA\NotesTutorial\Settings;

use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\Settings\ISettings;

class NotesAdmin implements ISettings {

    /** @var IL10N */
    private $l;

    /** @var IURLGenerator */
    private $urlGenerator;

    /** @var IConfig */
    private $config;

    /** @var IL10N $l*/
    private $l;

    public function __construct(IConfig $config, IL10N $l) {
        $this->config = $config;
        $this->l = $l;
    }

    /**
     * @return TemplateResponse
     */
    public function getForm() {
  $parameters = array('key' => 'test');

        return new TemplateResponse('notestutorial', 'admin', $parameters, '');  
    }

    public function getSection() {
        return 'notestutorial'; // Name of the previously created section.
    }

    /**
     * @return int whether the form should be rather on the top or bottom of
     * the admin section. The forms are arranged in ascending order of the
     * priority values. It is required to return a value between 0 and 100.
     *
     * E.g.: 70
     */
    public function getPriority() {
        return 10;
    }
}

This would be my code for the admin section:

<?php
namespace OCA\NotesTutorial\Sections;

use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\IIconSection ;

class NotesAdmin implements IIconSection {

    /** @var IL10N */
    private $l;

    /** @var IURLGenerator */
    private $urlGenerator;

    public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
        $this->l = $l;
        $this->urlGenerator = $urlGenerator;
    }

    public function getIcon() {
        return $this->urlGenerator->imagePath('notestutorial', 'app.svg');
    }

    public function getID() {
        return 'notestutorial';
    }

    public function getName() {
        return 'Notes tutorial';
    }

    public function getPriority() {
        return 98;
    }
}

And this is my info.xml:

<?xml version="1.0"?>
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
    <id>notestutorial</id>
    <name>Notes Tutorial</name>
    <summary>Test</summary>
    <description><![CDATA[test]]></description>
    <version>0.0.2</version>
    <licence>agpl</licence>
    <author mail="testmail" >Julia</author>
    <namespace>NotesTutorial</namespace>
    <category>tools</category>
    <bugs>http://test.com</bugs>
    <dependencies>
        <nextcloud min-version="19" max-version="22"/>
    </dependencies>
    <settings>
        <admin>OCA\NotesTutorial\Settings\NotesAdmin</admin>
    	<admin-section>OCA\NotesTutorial\Sections\NotesAdmin</admin-section>
    </settings>
</info>

And this is my admin.php file in the templates folder:

<?php
script('notestutorial', 'admin');
style('notestutorial', 'admin');
?>

<div id="admin">
<h2>TEST</h2>
</div>


do you have a repository ?

No I am sorry, but the code is like the appskeleton
plus the changes I’ve already posted.

so,

I added a missing line in Settings\NotesAdmin.php

use OCP\IURLGenerator;

Note that your have 2 definitions of private $l; in this file.

I added an app.svg in app_root/img/

and voila:

Selection_002

If after the fix it is still not working, might comes from the location of your files.

1 Like

Now it works, thank you very much. :grinning: