Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category selection: Expose all category fields to Twig template #7358

Open
FlxRobole opened this issue Apr 10, 2024 · 0 comments
Open

Category selection: Expose all category fields to Twig template #7358

FlxRobole opened this issue Apr 10, 2024 · 0 comments
Labels
Feature New functionality not yet included in Sulu

Comments

@FlxRobole
Copy link
Contributor

Problem description

I encounter this issue is at the threshold of Bug/Feature.

Context: Our company is working on a list view that can be filtered from within the frontend. Filterable list items can be added via a block, each block item having a "category_selection" field. A dump of the item's category looks like the following in Twig:

array:11 [▼
  "id" => 9
  "key" => "privatperson"
  "name" => "Privatperson"
  "description" => null
  "meta" => []
  "keywords" => []
  "defaultLocale" => "de"
  "creator" => "Adam Ministrator"
  "changer" => "Adam Ministrator"
  "created" => DateTime @1712736941 {#4987 ▶}
  "changed" => DateTime @1712736941 {#4986 ▶}
]

Now, compare this to an item returned via sulu_categories():

array:15 [▼
  "locale" => "de"
  "id" => 10
  "key" => "unternehmen"
  "defaultLocale" => "de"
  "name" => "Unternehmen"
  "description" => null
  "medias" => array:1 [▶]
  "ghostLocale" => "de"
  "meta" => []
  "creator" => "Adam Ministrator"
  "changer" => "Adam Ministrator"
  "created" => "2024-04-10T08:15:51"
  "changed" => "2024-04-10T08:15:51"
  "children" => []
  "parentId" => 7
]

Problem: Categories exposed by category_selection content type miss some field (e.g. ghostLocale, medias and most importantly parentId which we require to filter items in the frontend). There is no Twig function to resolve a full category (e.g., sulu_category_load) and no properties parameter as for e.g. smart_content to explicitly define the fields that should be resolved

Proposed solution

Depending on what fits best to the Sulu flavor of configuring content-types, either

  1. Always expose all fields/values of a category to the Twig template so that it is identical with the items returned by sulu_categories()
  2. OR add a properties collection-type parameter to category_selection
  3. OR add a Twig function sulu_category_load to CategoriesBundle
@FlxRobole FlxRobole added the Feature New functionality not yet included in Sulu label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New functionality not yet included in Sulu
Projects
None yet
Development

No branches or pull requests

1 participant