Add byline support

Created on 8 November 2023, over 1 year ago

Problem/Motivation

I am doing a migration now and some pages have a byline, for example: https://www.canada.ca/en/revenue-agency/services/tax/registered-plans-administrators/registered-disability-savings-plans-rdsps/payments.html

This feature should also take into consideration that the new provisional Topic template also includes a byline (bottom of page) which can be multi-valued. And for the stable topic template this can be seen as the Contributors links.

Proposed resolution

Create a new vocabulary to store the possible selections for the byline field. This allows content admins to enter the name and URL for each department once, and content authors only need to select a term on any given node (reducing mistakes and inconsistencies).

Create a new Byline field and add it to the page content type. Do the necessary theming and preprocessing to render the link field on the new vocab instead of a link to the term itself.

User interface changes

Trying to add this new field to the page content type as currently configured was proving difficult. The page content type uses layouts, but it only seems to work well when no layout is selected. If the Default or Two Column layout is selected then tabs do not show up, as wel as other inconsistencies. Also since page really only has one body field there isn't anything meaningful to add to a second column. For this reason, my patch removes layout on the page content type which really simplifies things. On all projects I end up ditching page content type and just building a new one since layout is not required, and if it was required I would prefer to add it to a content type myself.

Data model changes

Add a new field to the page content type, in the right sidebar, called Byline.

Feature request
Status

Active

Version

5.0

Component

Code

Created by

🇨🇦Canada smulvih2 Canada 🍁

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

Comments & Activities

  • Issue created by @smulvih2
  • 🇨🇦Canada smulvih2 Canada 🍁
  • Status changed to Needs review over 1 year ago
  • 🇨🇦Canada smulvih2 Canada 🍁

    Patches added for WxT and wxt_bootstrap.

  • 🇨🇦Canada smulvih2 Canada 🍁

    I tested adding the byline field to other content types and it works as expected. Just need to add the existing field_byline to the content type and adjust the display on node view/edit.

  • 🇨🇦Canada danrod Ottawa

    Hi @smulvih2 I am having issue when patching WxT with the patch file wxt-byline-3400277-3.patch:

  • 🇨🇦Canada smulvih2 Canada 🍁

    @danrod I made this off of the 5.0.x-dev branch, maybe you need to switch branches?

  • 🇨🇦Canada danrod Ottawa

    Thanks @smulvih2 I was able to test this, I created a few terms in the "Departments" vocabulary, which were also displayed as list options in the "Byline" field on the "Basic Page" content type, this field was also rendered with no issues.

  • 🇨🇦Canada web247 Toronto

    Just bumping into this, will this be incorporated in the 5.4.x - 6.1.x branch? One of my clients could benefit from it.

    Please let us know and we can rewrite the patches to make it work with the latest branches.

  • 🇨🇦Canada smulvih2 Canada 🍁

    @web247 yes let's get this into 5.4.x and 6.1.x. If you re-roll the patches that would be great, I can merge them in and test. You will notice the patches in #3 also simplify the page content type, removes the sidebar and layout (layout builder).

  • 🇨🇦Canada web247 Toronto

    I have the patches for the wxt54x branch, they add the fields and the needed changes, but for some reason it doesn't set up the page content type correctly, because it sets the fields as "Disabled" in the form display even though it is clear in the patches that they should be displayed, I don't know how to fix this, so I'll pass on this issue, any takers?

    This is how it looks after the patch:

    The config in the patch has a different configuration:

    diff --git a/modules/custom/wxt_ext/wxt_ext_page/config/optional/core.entity_form_display.node.page.default.yml b/modules/custom/wxt_ext/wxt_ext_page/config/optional/core.entity_form_display.node.page.default.yml
    index 14a99018..ddb9f541 100644
    --- a/modules/custom/wxt_ext/wxt_ext_page/config/optional/core.entity_form_display.node.page.default.yml
    +++ b/modules/custom/wxt_ext/wxt_ext_page/config/optional/core.entity_form_display.node.page.default.yml
    @@ -1,18 +1,40 @@
    +uuid: 7931bce3-8cfd-44b0-932a-309a4770d785
     langcode: en
     status: true
     dependencies:
       config:
         - field.field.node.page.body
    -    - field.field.node.page.layout_builder__layout
    -    - field.field.node.page.layout_builder__translation
    -    - field.field.node.page.layout_selection
    +    - field.field.node.page.comment
    +    - field.field.node.page.field_byline
         - field.field.node.page.field_lead_title
    +    - field.field.node.page.field_meta_tags
         - node.type.page
    +    - workflows.workflow.editorial
       module:
         - content_moderation
    +    - field_group
         - metatag
         - path
         - text
    +third_party_settings:
    +  field_group:
    +    group_byline:
    +      children:
    +        - field_byline
    +      label: Byline
    +      region: content
    +      parent_name: ''
    +      weight: 14
    +      format_type: details_sidebar
    +      format_settings:
    +        classes: ''
    +        show_empty_fields: false
    +        id: ''
    +        label_as_html: false
    +        open: false
    +        description: ''
    +        required_fields: true
    +        weight: 0
     id: node.page.default
     targetEntityType: node
     bundle: page
    @@ -20,95 +42,109 @@ mode: default
     content:
       body:
         type: text_textarea_with_summary
    -    weight: 6
    +    weight: 2
    +    region: content
         settings:
           rows: 9
           summary_rows: 3
           placeholder: ''
    +      show_summary: false
         third_party_settings: {  }
    -    region: content
       created:
         type: datetime_timestamp
    -    weight: 2
    +    weight: 5
    +    region: content
         settings: {  }
         third_party_settings: {  }
    +  field_byline:
    +    type: options_select
    +    weight: 16
         region: content
    +    settings: {  }
    +    third_party_settings: {  }
    +  field_lead_title:
    +    type: string_textfield
    +    weight: 1
    +    region: content
    +    settings:
    +      size: 60
    +      placeholder: ''
    +    third_party_settings: {  }
    +  field_meta_tags:
    +    type: metatag_firehose
    +    weight: 13
    +    region: content
    +    settings:
    +      sidebar: true
    +      use_details: true
    +    third_party_settings: {  }
       langcode:
         type: language_select
    -    weight: 2
    +    weight: 3
         region: content
         settings:
           include_locked: true
         third_party_settings: {  }
    -  layout_selection:
    -    type: options_select
    -    region: content
    -    weight: 102
    -    settings: {  }
    -    third_party_settings: {  }
       moderation_state:
         type: moderation_state_default
    -    weight: 100
    -    settings: {  }
    +    weight: 11
         region: content
    +    settings: {  }
         third_party_settings: {  }
       path:
         type: path
    -    weight: 5
    +    weight: 10
    +    region: content
         settings: {  }
         third_party_settings: {  }
    -    region: content
       promote:
         type: boolean_checkbox
    +    weight: 8
    +    region: content
         settings:
           display_label: true
    -    weight: 3
         third_party_settings: {  }
    +  simple_sitemap:
    +    weight: 6
         region: content
    +    settings: {  }
    +    third_party_settings: {  }
       status:
         type: boolean_checkbox
    -    weight: 10
    +    weight: 12
    +    region: content
         settings:
           display_label: true
         third_party_settings: {  }
    -    region: content
       sticky:
         type: boolean_checkbox
    +    weight: 9
    +    region: content
         settings:
           display_label: true
    -    weight: 4
         third_party_settings: {  }
    -    region: content
       title:
         type: string_textfield
         weight: 0
    +    region: content
         settings:
           size: 60
           placeholder: ''
         third_party_settings: {  }
    -    region: content
    -  field_lead_title:
    -      type: string_textfield
    -      weight: 1
    -      region: content
    -      settings:
    -        size: 60
    -        placeholder: ''
    -      third_party_settings: {  }
       translation:
    -    weight: 10
    +    weight: 7
         region: content
         settings: {  }
         third_party_settings: {  }
       uid:
         type: entity_reference_autocomplete
    -    weight: 1
    +    weight: 4
    +    region: content
         settings:
           match_operator: CONTAINS
    +      match_limit: 10
           size: 60
           placeholder: ''
         third_party_settings: {  }
    -    region: content
     hidden:
    -  layout_builder__layout: true
    -  layout_builder__translation: true
    +  comment: true

    Has anyone encountered the same issue? I'd love a second opinion on this

  • 🇨🇦Canada web247 Toronto

    Finally I was able to work the functionality in the 5.4.x but I had a few issues

    - I added the config settings in these files:

    modules/custom/wxt_ext/wxt_ext_page/config/optional/core.entity_form_display.node.page.default.yml
    modules/custom/wxt_ext/wxt_ext_page/config/optional/core.entity_view_display.node.page.default.yml
    

    But for some reason some of the fields were hidden by default, and the widget that holds the byline options didn't work at all, so I got rid of it

    - I tried adding some workaround PHP code at modules/custom/wxt_ext/wxt_ext_page/wxt_ext_page.install in a new function, wxt_ext_page_update_8501 but the function just neved executed, is there an issue with the functions at this install file? They don't seem to be working

    - As a last resort, I had to add my workaround code at

    modules/custom/wxt_ext/wxt_ext_page/wxt_ext_page.module

    , in the function wxt_ext_page_form_alter, but this is far from a good solution.

    Here's some screens of the byline functionality and page rendering:



    I'll create patches for the 6.1.x branch for now, I'm open to rewrite the patches if the workaround solution doesn't satisfy anyone

  • 🇨🇦Canada smulvih2 Canada 🍁

    @web247 yes I remember having some issues with field being added to the content type but being hidden by default. This shouldn't require any code to resolve, just config, but the config is very picky and needs to be just right in order to work. If you can post a patch or create an MR I can take a look. It could be due to config dependencies; need to make sure that the field config is installed before it's added to the form.

  • 🇨🇦Canada web247 Toronto

    Good Morning @smulvih2 yes, sorry, forgot to attach the latest patches !

    Please have a look if you have some time, meanwhile I'll create patches for the 6.1.x while we figure it out the hidden fields issue.

Production build 0.71.5 2024