Sulu: Custom Webspace Settings

Created on 13 Apr 2017  路  9Comments  路  Source: sulu/sulu

| Q | A
| --- | ---
| Bug? | no
| New Feature? | yes

Actual Behavior

There is no feature like this.

Expected Behavior

I would like to have the possibility to add a new tab into the webspace settings for custom fields. Like the websites-logo or key colors or main configurations what change the whole website.

Steps to Reproduce


Possible Solutions

when you add a xml template path under your webspace xml like:
<configuration>app/resources/config/webspacenameConfig.xml</configuration>

Feature To Discuss

Most helpful comment

@plozmun Right, this should already be possible to build on your own, but this specific use case should be easier to implement :slightly_smiling_face:

All 9 comments

In my opinion I would not add a path I would allow the properties tag of the template definition inside the Webspace.xml and show under Webspace Settings a tab Content. We can store this data inside cmf/<webspace_key> node. On the website a webspace variable or a twig extension could return this data. /cc @sulu/core-team

Hi @Quehnie, as the feature was not implemented, I'm curious about how you solved it. Can you maybe describe that ?
Thanks ! 馃憤

Hey @aubryfr in this case we created a snippet, which we added as default snippet for the webspace so we can load it with sulu_snippet_load_default. I think this is the best possible solution at the moment.

http://docs.sulu.io/en/latest/reference/twig-extensions/functions/sulu_snippet_load_default.html

This would really be a fantastic feature. Just add some content types as "settings" to the webspace.xml and get a new tab in the backoffice where you now can add data. <3

In sulu 2.0 you can extend the webspace panel with your custom implementation.
Maybe some docs to do this is missing but it's possible. Look here:
https://github.com/sulu/sulu/blob/master/src/Sulu/Bundle/WebsiteBundle/Admin/WebsiteAdmin.php#L92
You can create your Admin class with "Sulu extend admin" documentation and set parent

->setParent(PageAdmin::WEBSPACE_TABS_VIEW)

@plozmun Right, this should already be possible to build on your own, but this specific use case should be easier to implement :slightly_smiling_face:

@aubryfr @Quehnie
We had the same problem. And solved it like this.

  • Made custom admin to configure views, add settings permissions and add navigation items (General)
  • Made custom view in react
  • Parse website_settings.xml into FormStore
  • Made custom API endpoint to save and get global settings
  • Provide the settings to TWIG so we can do {{ settings.companyName }} in any twig file and will get the company name

We experienced that snippets and settings default snippets is somewhat confusing to customers.

I included a GIF:

Dec-14-2020 16-57-35

@jordygroote Nice solution! Implementing a basic settings entity should even be possible without adding custom Javascript. The trick is to set a default for the id attribute of the form view to make Sulu load the entity from the server 馃檪
I just added an example for this here: https://github.com/sulu/sulu-demo/pull/88

Be aware that the example above implements a global application settings entity, not a webspace specific one. If you dont want to use a default snippet for webspace-specific settings, you could implement this in a similar way to the example. This would need at least the following adjustments:

Thanks a lot for the answer, @jordygroote!
(I'm not working with this at all anymore, but @valentinwatel might be interested)

Was this page helpful?
0 / 5 - 0 ratings