Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODX resources can be "saved" without a pagetitle #14564

Open
pmacswebteam opened this issue Apr 18, 2019 · 8 comments
Open

MODX resources can be "saved" without a pagetitle #14564

pmacswebteam opened this issue Apr 18, 2019 · 8 comments
Assignees
Labels
bug The issue in the code or project, which should be addressed. type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript.

Comments

@pmacswebteam
Copy link

Bug report

Summary

MODX resources can be "saved" without a pagetitle

Step to reproduce

  1. Create a resource with a "space" in the pagetitle field
  2. Save the resource
  3. Resource is automatically renamed to "Untitled Resource"
  4. Removed "Untitled Resource" text & replace with a "space"
  5. Save

Observed behavior

Resource is saved with no pagetitle

Expected behavior

User should be prompted to enter a pagetitle with real text (not just spaces) before being able to save.

Environment

MODX version, apache/nginx and version, mysql version, browser, etc. Any relevant information.

MODX 2.7.1

@JoshuaLuckers JoshuaLuckers added type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript. bug The issue in the code or project, which should be addressed. state/accepting-pull-request labels Apr 19, 2019
@JoshuaLuckers JoshuaLuckers added this to the v2.7.2 milestone Apr 19, 2019
@opengeek opengeek modified the milestones: v2.7.2, v2.7.3 Sep 26, 2019
@Ruslan-Aleev
Copy link
Collaborator

Ruslan-Aleev commented Oct 19, 2019

The bug, as it turned out, is still relevant for Templates, Categories and Files. You can create them with spaces instead of a name (for a file there will be, for example: " .txt").

@Ruslan-Aleev
Copy link
Collaborator

For MODX3, this problem is also relevant, although for resources the bug works slightly differently.

@smg6511
Copy link
Collaborator

smg6511 commented Jul 21, 2020

Please ignore the referenced pull above (#15146) ... I jumped the gun, so to speak, when replying that it addressed this particular issue. I removed my comment, but the pull reference remains.

@smg6511
Copy link
Collaborator

smg6511 commented Sep 23, 2020

OK, I'm going to jump in and work up a solution. One question: Should there ever be an instance where a resource, element, or file name is allowed to begin with white space? My feeling is no. The answer to this question may inform how to go about making the change.

@smg6511
Copy link
Collaborator

smg6511 commented Sep 27, 2020

As I work on this, I find myself questioning the usefulness of auto-generating the "Untitled Resource" title and alias to begin with (at least in the way it currently happens). As I play with it (in both 2.x and 3.x), it seems to only apply when you happen to enter only whitespace into the pagetitle field. (Forgive me if I'm missing something in that regard.) As one would expect, an initially-empty field generates a validation error. So why would this not be the case for what is programatically-empty (i.e., only spaces)? Note that I realize there's a nuance in resource naming in that there's a use-case for allowing "0" as a pagetitle/alias, which is why the processors should test for null or an empty string rather than using php empty().

If the intention is to allow the saving of one or more untitled documents, then I'd argue it needs to be gone about in a different and more predictable way. Brainstorming it a bit, maybe ...

  1. Create a boolean system setting, such as "Auto-Generate Page Titles." If this was set to "Yes" then...
  2. Generate the "Untitled Resource" placeholder and create an indexed alias (to account for collisions that would otherwise occur when using FURLs and creating more than one untitled resource in the same container); the most sensible strategy might be to use the document id as the index, for example "untitled-resource-[resource id]"
  3. A couple nice ui features then would be to
    • provide warning when the resource is set to/changed to "published" and the pagetitle still contains the placeholder value
    • automatically replace the placeholder alias when an actual pagetitle is entered

What do you all think? If this functionality is warranted, I'd consider it more of a near-future enhancement and just fix the buggy behavior at this point.

@JoshuaLuckers
Copy link
Contributor

For 2.x we should fix the buggy behavior, in 3.x we can improve the behavior if needed.

@Ruslan-Aleev
Copy link
Collaborator

In general, for the 2.x branch, I made a solution, but only for resources #14800 Although there is a problem for elements and files.
It would be great to fix this bug for 2.x. And for 3.x already add functionality, for example, with "untitled-resource- [resource id]".

@Mark-H
Copy link
Collaborator

Mark-H commented Oct 4, 2020

See my comment here.

I'd be okay with preventing the empty pagetitle from being used in create (noting the special behavior when a resource is reloaded pre-save for switching templates) but don't really have too many strong feelings on the topic.

@opengeek opengeek removed this from the v2.8.0 milestone Oct 8, 2020
@smg6511 smg6511 self-assigned this Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed. type-frontend Issues related to UI/UX issues, mostly about styles and frontend implementations on JavaScript.
Projects
None yet
Development

No branches or pull requests

7 participants