Separate list of exception days?

Created on 6 April 2023, about 1 year ago
Updated 12 April 2023, about 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 about 1 year ago
  • πŸ‡³πŸ‡±Netherlands johnv
Production build 0.69.0 2024