Separate list of exception days?

Created on 6 April 2023, over 1 year ago
Updated 12 April 2023, over 1 year ago

Problem/Motivation

I'm trying to generate two elements; a table for the regular office hours, and a separate list for the exception days. By default, exception days are being added to the table-element in Twig, but is there a way to render them separately?

Feature request
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

🇧🇪Belgium fbreckx Antwerp

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @fbreckx
  • 🇳🇱Netherlands johnv

    You may copy/change the complex formatter, (which is a list of formatters) and remove the regular hours.

  • 🇧🇪Belgium fbreckx Antwerp

    Oh sorry, I forgot to mention I was trying to do this with views. Is it possible as well? Don't see any formatting options there.

  • 🇳🇱Netherlands johnv

    In principle, any setting that you find on the node formatter, should be available in Views Field.
    If not, additional information must be provided by the module

  • 🇧🇪Belgium fbreckx Antwerp

    The problem is, as far as I can see, is that the 'Exception Day Widget' is only available at the node Form Display tab. My idea was to set it up in views (one field formatted as the regular office hours, one field only exception days), but you can't format it that way, it seems.

    Rendering the entity twice directly in Twig, but with different display modes, doesn't work as well. Like so:

    {{ drupal_entity('node', 68, 'office_hours') }}
    {{ drupal_entity('node', 68, 'exception_days') }}

    As soon as you hide the days, the exception days dissapear as well.

  • 🇳🇱Netherlands johnv

    "My idea was to set it up in views (one field formatted as the regular office hours, one field only exception days), but you can't format it that way, it seems."

    Yes that is possible.
    Only problem is that there is no setting in the formatter to remove/hide the regular hours.

    Apart from overriding the formatter, you may change the prprocess function in office_hours_theme.inc file.

  • 🇧🇪Belgium fbreckx Antwerp

    Apart from overriding the formatter, you may change the prprocess function in office_hours_theme.inc file.

    Sadly, that's beyond my knowledge :)

  • 🇳🇱Netherlands johnv

    These issues seem to have the same request:
    💬 getValue() does not return all values when preprocessing Fixed
    Separate list of exception days? Closed: works as designed

  • 🇳🇱Netherlands johnv

    I think you need to add the attached file to your project.
    - rename the file
    - check the @todo's.

  • 🇳🇱Netherlands johnv

    from #5: "The problem is, as far as I can see, is that the 'Exception Day Widget' is only available at the node Form Display tab."
    You need the Widget to maintain the data in the node, then the Formatters to use in the Views view.

  • 🇧🇪Belgium fbreckx Antwerp

    Thanks! I've added the file to Plugin/ Field / Fieldformatter directory and renamed it to .php.
    But no extra formatter is appearing (caches were cleared).

    Should I do anything else besides this?

  • 🇳🇱Netherlands johnv

    Oops, please change line 5:

     * @FieldFormatter(
     *   id = "office_hours_only_exceptions",
     *   label = @Translation("Only exceptions"),
    
  • 🇧🇪Belgium fbreckx Antwerp

    Works like a charm. Many thanks!

  • Status changed to Closed: works as designed over 1 year ago
Production build 0.71.5 2024