sulu / sulu-standard

This repository is not longer the recommended way to start a sulu project. Use:
https://github.com/sulu/skeleton
MIT License
614 stars 106 forks source link

is It possible to add new custom element on webspace? #708

Open rodrigomanara opened 8 years ago

rodrigomanara commented 8 years ago
Q A
Bug? no
New Feature? no/yes
Sulu Version 1.2.2
<environments>
                <environment type="prod">
                    <panel_id>100903</panel_id>
                    <urls> 
                        <url>mys.local/{localization}</url>
                    </urls>
                </environment>
                <environment type="stage"  >
                    <panel_id>100902</panel_id>
                    <urls> 
                        <url>int.mys.local/{localization}</url>
                    </urls>
                      </environment>
                <environment type="dev" >
                    <panel_id>100901</panel_id>
                    <urls>
                        <url>dev.mys.local/{localization}</url>
                    </urls>
                </environment>
            </environments>
$ app/console sulu:build dev
Build Targets
=============

+---+--------------------+-----------------------------------------------------------------------+
| # | Builder            | Deps                                                                  |
+---+--------------------+-----------------------------------------------------------------------+
| 0 | database           |                                                                       |
| 1 | phpcr              | database                                                              |
| 2 | phpcr_migrations   | phpcr                                                                 |
| 3 | fixtures           | database, phpcr                                                       |
| 4 | user               | fixtures, database                                                    |
| 5 | system_collections | database, fixtures                                                    |
| 6 | dev                | database, fixtures, phpcr, user, phpcr_migrations, system_collections |
+---+--------------------+-----------------------------------------------------------------------+

Options:

  - nodeps: false
  - destroy: false
  - help: false
  - quiet: false
  - verbose: false
  - version: false
  - ansi: false
  - no-ansi: false
  - no-interaction: false
  - shell: false
  - process-isolation: false
  - env: 'dev'
  - no-debug: false

Look good? (y)Y

Executing builders
==================

Target: database

    doctrine:schema:update  ({"--force":true})

        Nothing to update - your database is already in sync with the current entity metadata.

Target: phpcr

    sulu:document:initialize

        sulu_document_manager.initializer.workspace
          [ ] workspace: "default"
        sulu_content.document_manager.content_initializer
          content namespaces:
          [ ] sulu:http://sulu.io/phpcr
          [ ] sec:http://sulu.io/phpcr/sec
          [ ] settings:http://sulu.io/phpcr/settings
          [ ] i18n:http://sulu.io/phpcr/locale
          content node types:
          [*] sulu:base
          [*] sulu:path
          [*] sulu:content
          [*] sulu:snippet
          [*] sulu:page
          [*] sulu:home
        sulu_custom_urls.initializer
        [2016-06-07 13:26:49] app.WARNING: Error: "[ERROR 1871] Element '{http://schemas.sulu.io/webspace/webspace}portal_id': This element is not expected. Expected is ( {http://schemas.sulu.io/webspace/webspace}urls ). (in file:/C:/xampp/htdocs/www/sulu-standard/ - line 54, column 0) [ERROR 1871] Element '{http://schemas.sulu.io/webspace/webspace}portal_id': This element is not expected. Expected is ( {http://schemas.sulu.io/webspace/webspace}urls ). (in file:/C:/xampp/htdocs/www/sulu-standard/ - line 60, column 0)" in "C:\xampp\htdocs\www\sulu-standard\app\Resources\webspaces\gtm.local.xml". The file has been skipped.
                [2016-06-07 13:26:49] app.WARNING: Error: "[ERROR 1871] Element '{http://schemas.sulu.io/webspace/webspace}panel_id': This element is not expected. Expected is ( {http://schemas.sulu.io/webspace/webspace}urls ). (in file:/C:/xampp/htdocs/www/sulu-standard/ - line 48, column 0) [ERROR 1871] Element '{http://schemas.sulu.io/webspace/webspace}panel_id': This element is not expected. Expected is ( {http://schemas.sulu.io/webspace/webspace}urls ). (in file:/C:/xampp/htdocs/www/sulu-standard/ - line 54, column 0) [ERROR 1871] Element '{http://schemas.sulu.io/webspace/webspace}panel_id': This element is not expected. Expected is ( {http://schemas.sulu.io/webspace/webspace}urls ). (in file:/C:/xampp/htdocs/www/sulu-standard/ - line 60, column 0)" in "C:\xampp\htdocs\www\sulu-standard\app\Resources\webspaces\mys.local.xml". The file has been skipped.
                  sulu.local:
          [ ] items path:: /cmf/sulu_local/custom-urls/items
          [ ] items path:: /cmf/sulu_local/custom-urls/routes
        sulu_snippet.document.snippet_initializer
          [ ] snippet path:: /cmf/snippets
        sulu_core.webspace.document_manager.webspace_initializer
          [ ] homepage: /cmf/sulu_local/contents (en)
          [ ] homepage: /cmf/sulu_local/contents (de)

                * Legend: [+] Added [*] Updated [ ] No change

Target: phpcr_migrations

Target: fixtures

    doctrine:fixtures:load  ({"--no-interaction":true,"--append":false})

          > purging database
          > loading [1] Sulu\Bundle\ContactBundle\DataFixtures\ORM\LoadCountries
          > loading [2] Sulu\Bundle\ContactBundle\DataFixtures\ORM\LoadDefaultTypes
          > loading [3] Sulu\Bundle\MediaBundle\DataFixtures\ORM\LoadCollectionTypes
          > loading [4] Sulu\Bundle\MediaBundle\DataFixtures\ORM\LoadMediaTypes
          > loading [5] Sulu\Bundle\SecurityBundle\DataFixtures\ORM\LoadSecurityTypes

    sulu:document:fixtures:load  ({"--no-interaction":true})

        Could not find any candidate fixture paths.

Target: user

    sulu:security:role:create  ({"name":"User","system":"Sulu"})

        Created role "User" in system "Sulu".

        Created role "User" in system "Sulu"
    sulu:security:user:create  ({"username":"admin","firstName":"Adam","lastName":"Ministrator","email":"admin@example.com","locale":"de","role":"User","password":"admin"})

        Created user "admin" in role "User"

        Created user "admin" with password "admin"
Target: system_collections

Target: dev
alexander-schranz commented 8 years ago

You can not add custom attributes in the webspace, for me this also doesnt look as the right space for your case.

Add the following into the parameters.yml.dist file:

    panel_id: ~

Run composer install

This will ask you to enter the panel_id for the current system, in your case on dev you enter 100901.

You need to access this in twig? Then you need to write a twig extension and give your parameter in the service registration the consturctor <argument>%panel_id%</argument>.

rodrigomanara commented 8 years ago

I see, thank you, for your clarification but parameters will not be able to handle this for me, as every panel has it own ID and also a custom URL for every single panel, the right way for me would be having it on webspaces. I will need to build a feature for it.

alexander-schranz commented 8 years ago

When parameter is not the way to go you need to create your own configuration tree in the config.yml at current state:

e.g.:

client_website:
    panels:
        <webspace_key>:
            panel_id: 124124
            panel_url: http://....
        <webspace_key2>:
            panel_id: 124124
            panel_url: http://....

as you see in the app/config/website and app/config/admin there are different yml file for each environment. how to read the configuration you will find here http://symfony.com/doc/2.8/cookbook/bundles/configuration.html.

But if you only have only one webspace this makes more sense in the parameters.yml and is faster to use because for me this type of configuration goes into the same type as the database as another developer could maybe have another panel_id and panel_url as you when he is developing.

rodrigomanara commented 8 years ago

yes, I used this before but I wanted to have all under the same umbrella, thank you for your help is much appreciated

danrot commented 8 years ago

I don't know your exact requirements, but I could imagine that a feature like this might make sense in certain cases. But at the moment it is not possible. Maybe we should think about a solution to make this easily possible. An easy solution would be to add an options tag, which can store key value pairs.