Forum

Ask, reply and learn. Join the community of Akaunting.

New Discussion

Extension options for apps

Jan Keller   ( User )

Commented 3 years ago

I am looking into building apps/modules for Akaunting, but have a few questions on the "best practices" for extending core functionality.

Let's say I make an app to import users from another system. I would probably like to
- Add some information to the user profile/edit screen
- Add one or more database migrations
- Install additional composer dependencies

As I read the documentation for overriding output, I can override the *entire* user edit screen, but I don't want to do that, only add additional fields/information. Otherwise I would be competing with other apps that *also* want to change the user edit screen and also be vulnerable to core developments.
Is there an alternative "best practice" for this need?

According to the module folder structure documentation at https://github.com/akaunting/module/wiki/Folder-Structure I can just add migrations in the appropriate folder. Cool, but is it intentionally not in the Akaunting documentation at https://akaunting.com/docs/developer-manual/modules? Is there something I should worry about?

Similarly, the folder structure allows for a composer.json inside the module directory - is that the right way to go?

Bernhard Hörmann   ( User )

Commented 3 years ago

Two weeks, no reply. Thats not a good sign for someone who also wants to start develop a module. The documentation isn't that good, so that someone can jump start developing.

In your ` public function compose(View $view)` you can decide what you want to extend/override.

```
// Override just the 'content' section
$view->getFactory()->startSection('content', view('my-blog::customers.create'));

// Override the whole file
$view->setPath(view('my-blog::customers.create')->getPath());

// Push to a stack
$view->getFactory()->startPush('scripts', view('my-blog::script'));
```

In my case, I wanna add a button to the `/banking/transactions` screen, next to Import, Export etc. buttons.
So with developer toolsbars on, I found out, that this screen is the `banking.transactions.index` view. Looking into this file, I saw different sections. I needed the section `@section('new_button')` where the buttons are.

Now you can overwrite just this section:

```
$view
->getFactory()
->startSection('new_button', view('my-module::banking.transactions.new_button'));
```

and the section gets REPLACED by the content of my `new_button` view. Maybe this helps you to understand how it works.

My question is: How to EXTEND, not REPLACE the content. I thought adding `@parent` to the view would do the job, but it doesn't.

Please login or register to leave a response.

Showing 1 to 2 of 2 discussions