vanilophp/demo

Tweaking settings on admin page

Closed this issue · 17 comments

Is there any way to tweak settings forms on admin page like adding a custom field on existing settings form?

My goal is to tweak the app logo together with updating the app name via the settings page.

Hoping for the quick response.

Thanks.

UPDATE
I tried the approach on these docs: https://vanilo.io/docs/1.1/settings#adding-setting-to-the-ui but only the 3rd sample are working, the rest are not, especially in implementing the $settingsTreeBuilder->addSettingItem() method.

Specification/s:
Laravel Version: 6.2

Replacing the app logo in the admin from settings is not supported.

The image is taken from /public/imags/appshell/logo.svg - replacing that file will replace the logo as well.

I see and we manage to make that approach.
But it would be nice if it can manage the app logo from the admin settings page.
Do you have any idea or sample code to include the file input field below the app name field in the settings page general settings tab?

I've tried this approach in which I include in the AppServiceProvider.php:

$settingsTreeBuilder = $this->app['appshell.settings_tree_builder'];
$settingsGearsRegistry = $this->app['gears.settings_registry'];

// Register the setting:
$settingsGearsRegistry->add(new SimpleSetting('appshell.ui.logo'));

// Add the setting to the AppShell UI
$settingsTreeBuilder
    ->addRootNode('others', 'Others', 110) // the id/label of the tab
    ->addChildNode('others', 'app_logo', 'Logo') // the id/label of the group within the tab
    ->addPreferenceItem('app_logo', ['select', ['label' => 'Logo']], 'appshell.ui.logo'); // The setting field itself

which is working but the output is in the "Others" tab in which I've created as coded above.
I want to include the "Logo" field below the App Name field on the general settings tab on the settings page.

Sample Image: https://prnt.sc/rf20rp

Thanks.

You need to extend the underlying gears library by defining a custom setting class and/or a custom backend.

But as said it's not supported out of the box.

Ps.: How frequently do you want to change the logo?

I see.

Is this what you meant? https://konekt.dev/gears/1.2/building-ui#tree-builder

We don't have an idea on where on Laravel files should put the sample code and on how to make sure it renders to the custom view file from the custom settings class so any sample code in implementing it is highly appreciated.

As I said before, I want to change the app logo via settings page general tabs form. Since the framework can save the inputted data from the text field on the form to database from custom setting class created in AppServiceProvider.php, I hope that you can help with file input approach and how to save the file data name to database.

My apologies for my bad grammar :(

What I'm trying to achieve is to have the admin the capability to change the app name together with app logo via the settings page, and on the future, if this issue is resolved, also can tweak the language on the app via the settings page.

Sorry, but what you'd like to implement is neither supported (at the moment) nor is a priority of the Vanilo project.

You need to implement it yourself using your Laravel superpowers ;)

I see. I'll guess I'm on my own now T_T

Thank you so much for the responses, appreciated much.

Good day.

I would rethink how crucial this feature for you is.

At the end of the day, you want to sell something, that's what brings you money.

Of course, if changing the logo frequently contributes to your revenue stream then it worths investing your time in this feature. Otherwise, I would deprioritize it.

Actually, it has a big impact and crucial when it comes to the client's perspective since they eventually want to change the app's logo with the app name.

Would love to hear if you can find this feature a solution so that other developers out there who use this framework will have relief if they are encounter this kind on issue.

Don't expect that, it's out of the framework's scope. But since it's a laravel app, it's completely under your control.

Update: Right now I'm working on AppShell v2.0 - the underlying component that powers Vanilo's admin panel. I'm adding support to take the logo uri from setting appshell.ui.logo_uri (default fallback to the config value)

I can't promise that file upload will also work, but at least you'll be a few steps closer to what you want to achieve.

I'll keep you posted, I plan to release it in the next few days.

Good day,

That's more like it. Looking forward to it.

I'm hopeful for the framework and its sub-packages to have straight-to-the-point, noob-friendly documentation. Actually, I have many hopes on this framework to be inlined with the true CMS capabilities but maybe this will take time since it is in early stages. But hopefully, your team will commit those roadmaps as soon as possible in order to apply automatically to those who use your framework, it would be a big help.

Thank you so much once again for the update 👍🏻

Hello, I've just started with Laravel and Vanilo few days ago and I came across the same problem as @noelc10:

I tried the approach on these docs: https://vanilo.io/docs/1.1/settings#adding-setting-to-the-ui but only the 3rd sample are working, the rest are not, especially in implementing the $settingsTreeBuilder->addSettingItem() method.

I tried to append some settings in general tab:

Sample Image: https://prnt.sc/rf20rp

but it was impossible.

I used this piece of code from mentioned docs:

$settingsTreeBuilder->addSettingItem('general_app', ['text', ['label' => __('My Setting')]], 'my.setting.key');

I put it in my boot() method of AppServiceProvider, but it was doing nothing.

So I was searching in code and found out, that settings tree is empty at that moment. It only gets populated in index() action of SettingsController by calling app('appshell.settings_tree'), so that is why we can't append to the general tab. Because general tab doesn't exist.

Solution:

We have to trigger populating of settings tree in a boot() method of AppServiceProvider by using:

$this->app['appshell.settings_tree'];

So you add logo field in General / Application settings like this:

$settingsRegistry = $this->app['gears.settings_registry'];
$settingsRegistry->addByKey('appshell.ui.logo_uri');

$this->app['appshell.settings_tree'];
$settingsTreeBuilder = $this->app['appshell.settings_tree_builder'];
$settingsTreeBuilder->addSettingItem('general_app', ['text', ['label' => __('Logo')]], 'appshell.ui.logo_uri');

Hi @briska, thanks for your analysis, it helped a lot! I could reproduce the issue locally, and I'm looking into it.
The problem comes from the AppShell package, so that is going to be fixed as soon as I find the root cause.

That extra $this->app['appshell.settings_tree']; call shouldn't be necessary at all.
Keep you updated.

@briska Run composer update konekt/appshell so that it updates AppShell to v1.8.1.
After the update, the call to $this->app['appshell.settings_tree']; is no longer necessary.

Thanks again for your contribution! 🙇

it works, thanks for quick fix :)

Hi @briska , thanks for your analysis and solution. It helps a lot for the other devs out there esp. me who are trying to figure out this kind of problem.

Will apply those fixes and post an update if it is working on my side.
Kudos 👍