Problem/Motivation

Looking for a way to make Maxlength module work with description metatag field on per-node metatags.

Steps to reproduce

Have a client who:
A) Uses Maxlength module along with Text Summary Options on their body summary to require summary text with a soft limit of 160 chars
B) Uses body summary to populate the description metatag.
C) Exposes certain Metatag fields, like description metatag, on node edit forms to allow overrides.
D) Wants a consistent UI for the description metatag override field, with the maxlength module countdown indicator.

Effectively, they want to permit longer body summary text for teasers and card displays with the soft limit, but enforce a hard limit of 160 on the metatag override field.

Proposed resolution

My initial guess is that this is just a small hook_form_alter() away. But I haven't looked into maxlength module's form api integration yet. So I wanted to capture this support request here so others can either chime in with their recipe — if one exists — or we can discuss and document a solution.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

jwilson3 created an issue. See original summary.

jwilson3’s picture

Issue summary: View changes
damienmckenna’s picture

Title: How to make metatag fields leverage maxlength module » Character count on fields with Maxlength integration (D9)
Category: Support request » Feature request
Related issues: +#1918738: Character count on fields via Maxlength integration (D7)

Let's make this a feature request.

We have support in the module for allowing meta tags to have a maximum length, so let's leverage that on the form output.

In D7 Maxlength integration could be handled by setting some elements in the form definition, maybe the D9+ version has something similar?

damienmckenna’s picture

Title: Character count on fields with Maxlength integration (D9) » Character count on fields via Maxlength integration (D9)
damienmckenna’s picture

Version: 2.0.x-dev » 8.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new4.78 KB

This matches the changes from the D7 issue.

damienmckenna’s picture

StatusFileSize
new4.78 KB

Typo on the settings form.

damienmckenna’s picture

@jwilson3: Let me know if this would work, I'd be happy to include this in the next release if it does. FYI I tested it with Maxlength v2.1.1.

jwilson3’s picture

Amazing! Thanks Damien for the first stab at this.

A read through of the patch looks good at first glance.

I'll take a closer look and test this week.

damienmckenna’s picture

James: Were you able to test it out? Does it cover what you were looking for?

papagrande’s picture

Status: Needs review » Reviewed & tested by the community

Yes, this would be very useful. Works for me on a D9 site.

  • DamienMcKenna committed 363c9fe9 on 8.x-1.x
    Issue #3356420 by DamienMcKenna, jwilson3, PapaGrande: Character count...
damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you both for your help with this.

  • DamienMcKenna committed cfcb6fd0 on 2.0.x
    Issue #3356420 by DamienMcKenna, jwilson3, PapaGrande: Character count...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jwilson3’s picture

I can now confirm that this feature is working great on a D10 site. My apologies that I was unable to test this earlier. I really appreciate you making time to get this done Damien! Thank you!

Some screenshots:

jwilson3’s picture

Found a spelling error "processsed" => "processed".

This will be truncated to a maximum of %max characters after any tokens are processsed.

Will open a follow-up.