Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-01-10 13:32:10

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Categories: Visual 'description limit' indication

I seem to want to category descriptions longer than the allowed 255 chars, which throws an error. I like the idea of using these meta fields to output descriptions on the public side more than I care about search engines (which I don’t at all).

For example a specific category of links, getting the description output above the list.

But this isn’t a smooth operation if I’m having to guess straws every time.

Would it be difficult to visually show when you’ve hit the character limit when drafting a description? I’ve seen this done in a couple of ways before. Sometimes a red background appears in the field when the character limit is exceeded, or a character countdown counter appears when you have 50 characters remaining, or whatever. Or maybe the text field is auto-sized to the character limit so when the limit is reached, you don’t see anymore text being typed and know to stop typing and start editing.

Maybe I can change (increase) the character limit somewhere, but even then it might be nice to have the visual cue in case I want my walls of text. Again, I value these fields more for my own content needs than the needs of search engines.

Btw, where do I change that limit?

Maybe that could be a preference field for convenience, too? In that case maybe the Help tip info at the category box is adjusted:

Category description

The category description is an optional component. It can help search engines and crawlers better identify and sort content, or it can be used to output descriptions as content in your site. A limit of 255 characters is set by default. You can change this limit in Preferences.

Then something like this at the preference item:

Number of characters for category descriptions. (?) [255]

Probably don’t have to say what the default is at this location if the value is already shown in the box.

And this in the Help tip:

If using category descriptions as meta descriptions for search engines, a max of 255 chars is recommended, though sometimes these limits are less depending on the indexing service.

Or whatever.

Last edited by Destry (2024-01-10 13:33:46)

Offline

#2 2024-01-10 15:09:57

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Re: Categories: Visual 'description limit' indication

I use a sticky article assigned to the relevant section or category when I need a broader description of its list. This is a quite simple way, and is also accessible through searches.

Offline

#3 2024-01-10 15:40:58

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: Categories: Visual 'description limit' indication

Destry wrote #336327:

Would it be difficult to visually show when you’ve hit the character limit when drafting a description?

This was a deficiency in pre-4.9.0 versions, sorry. We’ve “fixed” it in the upcoming release insofar as the browser has been told what the character limit is in text fields, and if you try to go over that, it will ignore/truncate anything beyond.

I’ve been experimenting with other constraints too over the last couple of months to trap/sanitize user input and have made some inroads, but not enough yet. I’m slowly coming round to the fact that hacking it isn’t the right approach, and it needs to be done “properly” which involves more database tables.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2024-01-10 15:54:22

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: Categories: Visual 'description limit' indication

Vienuolis wrote #336329:

I use a sticky article assigned to the relevant section or category when I need a broader description of its list. This is a quite simple way, and is also accessible through searches.

This is a perfect example for sections, that I’ve used before. For categories it does work – sort of – but since they are section agnostic, you need some way to link them to the category.

In this case, I’d be tempted to use pageless section content like this:

  1. Set up a section called meta_category or something and clear its page/css entries.
  2. Create an article in this hidden section with a title that exactly matches your category name (not Title).
  3. Write your category description text in the body and Save.
  4. Repeat for each category descriptor article.

Then in your page template that handles displaying your category landing pages, add something like:

...
<if::category>
   <article::custom section="meta_category" category='<txp:category />'>
      <txp:body />
   </article::custom>
</if::category>

Untested, but the general idea is that you grab the article from the hidden section that matches the current category given in the URL. Season to taste if you wish to display the category descriptor articles elsewhere by plugging in the relevant tag in the category attribute above.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2024-01-10 16:01:28

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Categories: Visual 'description limit' indication

That sounds like a good avenue, Bloke. Thanks. I’ll probably do that.

It just strikes me that, there’s this ‘description’ field, all neat and tidy for purpose. Why not use it to output a description.

Offline

#6 2024-01-10 16:50:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: Categories: Visual 'description limit' indication

Destry wrote #336333:

there’s this ‘description’ field, all neat and tidy for purpose. Why not use it to output a description.

Well you can. You just have to be… concise :p

There’s probably not much issue with expanding it actually. No reason it couldn’t be a maximum of 1024 or 2048 characters or something in the database. We’re only constrained by the row size limit of SQL, and there’s not much else in that table, so we can afford to bump it up a bit.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2024-01-10 21:15:44

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: Categories: Visual 'description limit' indication

Regardless, a visual indicator wouldn’t hurt. Please try this minimal one.

Offline

#8 2024-01-10 23:55:36

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,187
Website

Re: Categories: Visual 'description limit' indication

etc wrote #336339:

Regardless, a visual indicator wouldn’t hurt. Please try this minimal one.

Interesting – that works fine in Firefox 122beta, a little popover thingie appears at the maxlength limit. But nothing happens in Brave (Chromium) and Safari. No JS error(s) either.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#9 2024-01-11 11:26:09

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: Categories: Visual 'description limit' indication

Pity. Back to jquery-ui then. As a bonus, it’s stylable via .ui-tooltip.

Offline

#10 2024-01-11 11:57:56

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Categories: Visual 'description limit' indication

etc wrote:

Regardless, a visual indicator wouldn’t hurt.

+1 on that notion.

Um, in related news, anyone… I thought I knew how to actually output a category description, but I’m having trouble figuring it. In a particular situation I’m setting up a nested links page like Bloke describes here (btw, I can’t access page 3 of that thread where I posted, it throws an error about table and topic being out of sync).

The link form contents he describes looks something like this (he uses an ul, if I recall correctly):

<link::category title="1" wraptag="h2" />
<dl><+></dl>

I want to slip the description in between those:

<link::category title="1" wraptag="h2" />
<p>{Category description}</p>
<dl><+></dl>

I don’t see an attribute to use, but I’m sure I’ve seen a tag solution somewhere before. Can anyone slap me with that glove?

Offline

#11 2024-01-11 12:08:38

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,187
Website

Re: Categories: Visual 'description limit' indication

This?

<txp:if_description><p><txp:meta_description format="" escape="" /></p></txp:if_description>

Docs here

Last edited by phiw13 (2024-01-11 12:09:11)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#12 2024-01-11 12:19:14

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Categories: Visual 'description limit' indication

Heh. Yeah that. I had just found it and was racing here to avoid the slap, but you beat me to it. That studded glove stings.

Offline

Board footer

Powered by FluxBB