Updated: Comment #60

Problem/Motivation

When working with small-width templates, the long paths can destroy the nice look/layout of the template.

Proposed resolution

I suggest to cut (or wrap) paths on the administration page for the path module.

Remaining tasks

Reviews needed.

User interface changes

The paths on the administration page for the path module will be wrapped/cut.

API changes

None.

Original report by Bakus

Comments

dries’s picture

Status: Reviewed & tested by the community » Needs work

Coding style needs work. Not sure this is the proper solution.

killes@www.drop.org’s picture

Version: 4.7.0 » x.y.z

features go into HEAD

stevenpatz’s picture

Version: x.y.z » 7.x-dev
dave reid’s picture

Needs to be converted to use truncate_utf8().

dave reid’s picture

Title: Long paths destroy small templates » Truncate long paths and path aliases on admin/build/path
dave reid’s picture

Issue tags: +Novice

Adding Novice tag

ergonlogic’s picture

Status: Needs work » Needs review
StatusFileSize
new1.07 KB

Being a novice, I figure I'll take a crack at this. It seems fairly straight-forward, at least as far as truncating to 50 characters, as the original patch did. I also took the liberty of adding a 'title' attribute to each link with the full original path.

ergonlogic’s picture

StatusFileSize
new1.05 KB

Okay... How about I try to "Ensure the patch only contains unix-style line endings."

Freso’s picture

Status: Needs review » Needs work

Being a nitpicker (almost by trade), I have to point out that the good coding standards say not to have lines longer than 80 characters, even if this is sometimes ignored as other concerns outweigh it. In this case, however, there is a perfectly good solution for making the lines <=80 characters long: breaking up the array()s! :D

Give http://drupal.org/coding-standards#array a look, and all will be good. It's good seeing you go at 'em. :)

ergonlogic’s picture

StatusFileSize
new1.13 KB

Thanks for the encouragement! I was glad to discover the "Novice" tag, as the core issue queues can be intimidating.

ergonlogic’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, truncate_paths.patch, failed testing.

ergonlogic’s picture

Status: Needs work » Needs review
StatusFileSize
new1.11 KB

Grrr! Again with unix-style line endings.

jhodgdon’s picture

Status: Needs review » Needs work

Should use http://api.drupal.org/api/function/drupal_substr/7 instead of truncate_utf8. truncate_utf8 does a byte count, not a character count.

ergonlogic’s picture

Is there a reason to call drupal_substr() directly? All truncate_utf8() appears to do is provide optional parameters for making a sub-string respect word boundaries and add ellipses. It otherwise calls drupal_substr() to do the actual substring selection.

The Drupal 5 version appears to have performed a byte-count, if that helps...

Freso’s picture

Status: Needs work » Needs review

Setting back to "needs review" as the argument for "needs work" in #14 was responded to in #15.

dave reid’s picture

@jhodgdon Yep it's truncate_utf8 that should be used in this case, like all other cases in D7 with shortening & adding ellipses.

jhodgdon’s picture

Dave Reid: I was going by #200185: truncate_utf8() is used as a substring function.

Also, are we really sure that adding "..." is appropriate in all languages, such as Chinese for instance? I don't know, I'm just asking.

dave reid’s picture

@jhodgdon Oh I agree the truncate_utf8() function has been horribly misused for quite a while, and changing the function name is a big +1. We'd still be using that function here though, so it should stick with truncate_ut8() until it officially gets renamed right? The current patch is not using wordsafe.

jhodgdon’s picture

Correct - at least the current patch isn't using the truncate-to-a-word functionality...

What about the question of whether adding "..." is appropriate for all languages? I still don't know the answer to that one.

ergonlogic’s picture

According to the Wikipedia article, ellipses are used in many languages, including Chinese, though in that case, it is usually represented as 6 dots arranged vertically. It seems to me that the purpose of the $dots parameter is to "indicate an intentional omission," and that any logic about how (and whether) to represent it ought to be handled at the translation layer, since it's language specific.

While truncate_utf8() just adds ' ...', perhaps it should add t('&hellip;'), t('&#8230;'), or something similar instead. I don't know if passing HMTL entities or numeric character references is valid in t(), but you get the point. A translator with the appropriate knowledge could then provide the proper character(s) for his or her language.

Either way, I don't think it's something specific to truncating paths, and perhaps ought to be addressed in how truncate_utf8() handles it.

jhodgdon’s picture

Adding t('...') sounds like a good solution. I don't think using an HTML entity is a good idea, as much of the time truncate_utf8 is used for plain text.

But yes, it should be addressed on truncate_utf8(). I've just filed an issue:
#768040: truncate_utf8() only works for latin languages (and drupal_substr has a bug)

ergonlogic’s picture

#13: truncate_paths.patch queued for re-testing.

I believe the issues brought up about the patch in #13 have all been addressed, so I've submitted the patch for re-testing.

dave reid’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. Looking forward to the truncate_utf8 rename which shouldn't hold this up.

marcingy’s picture

Issue tags: -Novice

#13: truncate_paths.patch queued for re-testing.

Status: Reviewed & tested by the community » Needs work
Issue tags: +Novice

The last submitted patch, truncate_paths.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review
StatusFileSize
new1.06 KB

Reroll and amends to patch so as the code reflects the new array structure used for path aliases.

jhodgdon’s picture

Status: Needs review » Needs work

I think you need to wrap the HTML title attribute for l() in check_plain(), correct?

marcingy’s picture

Status: Needs work » Needs review

There is no need to add check_plain around the HTML attribute as drupal_attributes() performs the check_plain().

jhodgdon’s picture

Ah, you are correct. I think this patch is probably fine then, but I haven't personally tested it.

Hopefully the truncate_utf8() function issue will be fixed sometime, so that we can feel comfortable about using it for these purposes... right now it is waiting for a test debug, which I'll do when I have time, but if anyone else does:
#768040: truncate_utf8() only works for latin languages (and drupal_substr has a bug)

marcingy’s picture

See comment http://drupal.org/node/86461#comment-2803440 with regards that if this path needs to be revisited lets do that after the utf path lands.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Right. I wouldn't delay this patch because truncate_utf8() is not working as it should be. This patch should be fine once truncate_utf8() is fixed.

Anyway, I think the above patch is fine.

jhodgdon’s picture

#27: drupal.truncate.27.patch queued for re-testing.

int’s picture

Category: feature » task

change to task.

jhodgdon’s picture

#27: drupal.truncate.27.patch queued for re-testing.

sun’s picture

Status: Reviewed & tested by the community » Needs review

This patch somehow reminds me of #288039: URL alias admin page should include a link to the aliased URL

Please make sure that all discussed details from over there are taken into account in this patch.

sun’s picture

Issue tags: -Novice

#27: drupal.truncate.27.patch queued for re-testing.

jhodgdon’s picture

#27: drupal.truncate.27.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Novice

The last submitted patch, drupal.truncate.27.patch, failed testing.

jhodgdon’s picture

Status: Needs work » Needs review

That failure is bogus:
FAILED: [[SimpleTest]]: [MySQL] Setup environment: failed to clear checkout directory.

jhodgdon’s picture

#27: drupal.truncate.27.patch queued for re-testing.

Niklas Fiekas’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work
Issue tags: +Needs backport to D7

Needs to be rerolled for 8.x.

emclaughlin’s picture

Status: Needs work » Needs review
StatusFileSize
new978 bytes

Reroll

marvil07’s picture

Status: Needs review » Reviewed & tested by the community

It works as expected.

xjm’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs tests

Let's add an automated test for this. Thanks!

kristen pol’s picture

Issue summary: View changes

Updated issue summary.

dags’s picture

Assigned: Unassigned » dags
dags’s picture

StatusFileSize
new1.88 KB
new965 bytes

Adding automated test.

marvil07’s picture

Status: Needs review » Needs work
+++ b/core/modules/path/path.test
@@ -128,6 +128,18 @@ class PathAliasTestCase extends PathTestCase {
+    $this->assertNoText($alias, 'Th untruncated alias was not found.');

This looks RTBC, but there is a minor typo here.

dags’s picture

Status: Needs work » Needs review
StatusFileSize
new1.88 KB
new966 bytes

Oops. Fixing typo.

marvil07’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

ZenDoodles’s picture

Issue tags: -Needs tests

Reviewed patch and test. Looks good!

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Makes sense. Committed/pushed to 8.x, moving to 7.x for backport.

dags’s picture

StatusFileSize
new1.86 KB
new946 bytes

Backport.

dags’s picture

Status: Patch (to be ported) » Needs review
tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Diffstats are the same, test fails as expected. Looks good to me!

David_Rothstein’s picture

StatusFileSize
new34.97 KB

I reviewed this and it looks good to me, but can someone clarify why we are choosing 50 characters as the number to truncate at? That seems like an awfully small number. My laptop screen isn't that big, but there is still way way more room than 50 characters... making it look awfully funny to truncate that small (see attached screenshot).

Or maybe this issue is part of the mobile initiative? :)

David_Rothstein’s picture

Version: 7.x-dev » 8.x-dev
Status: Reviewed & tested by the community » Needs review

If we're going to change this in D7, I'm thinking we should do it only once... so I'm bumping this issue back to D8 for the moment (for my question above about whether 50 characters is too short for the truncation).

jp.stacey’s picture

Issue tags: -Novice

If there needs to be a high-level discussion about this, I will remove the "Novice" tag, because such a discussion would need input from the mobile initiative team rather than Drupal Ladderers like me...!

dags’s picture

Assigned: dags » Unassigned
Issue tags: +mobile, +D8UX usability
dags’s picture

Issue summary: View changes

Updated issue summary.

PavanL’s picture

Issue summary: View changes

Added Issue summary template.

thedavidmeister’s picture

Status: Needs review » Needs work

Isn't there a CSS rule to handle single-line-truncation-of-text-with-added-ellipsis for us client-side rather than trying to guess some perfect number of characters? http://css-tricks.com/snippets/css/truncate-string-with-ellipsis/

If we're not worried about IE10- support for this particular ellipsis, then we should totally use the CSS solution.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • catch committed 263c680 on 8.3.x
    Issue #86461 by ergonlogic, davidjdagino, marcingy, emclaughlin, Bakus:...

  • catch committed 263c680 on 8.3.x
    Issue #86461 by ergonlogic, davidjdagino, marcingy, emclaughlin, Bakus:...

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • catch committed 263c680 on 8.4.x
    Issue #86461 by ergonlogic, davidjdagino, marcingy, emclaughlin, Bakus:...

  • catch committed 263c680 on 8.4.x
    Issue #86461 by ergonlogic, davidjdagino, marcingy, emclaughlin, Bakus:...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

penyaskito’s picture

Why is this as needs work?

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

  • catch committed 263c680 on 9.1.x
    Issue #86461 by ergonlogic, davidjdagino, marcingy, emclaughlin, Bakus:...

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Version: 8.9.x-dev » 7.x-dev
Issue tags: +Bug Smash Initiative

This issue was committed in May 2012 and set for backport to Drupal 7. It was reopened to discuss why '50' was used as the length of the alias. There's been one comment about that in the intervening 11 years. In the meantime paths and path alias have been converted to entities with a length of 255.

Looking at Drupal 7 path.admin.inc I don't see that this change has been applied to Drupal 7, there is a patch in #53 for Drupal 7.

Therefore moving to the Drupal 7 issue queue.

quietone’s picture

Status: Needs work » Reviewed & tested by the community

The patch applies to D7, restoring the RTBC for the patch from #55.

poker10’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs reroll
StatusFileSize
new55.89 KB
new88.67 KB

Patch #53 does not apply anymore, it does needs a reroll (but read other thoughts below).

After reading the whole discussion and @David_Rothstein comments, I think that for D7 we have three options now:

1. Accept the rerolled #53 to the D7 - it is the same code as the current D9 code (checked it and aliases in D9 are still truncated to the 50 characters on the admin/config/search/path page , see the attached image).

2. Do not accept this and close this without commiting to the D7.

3. Reopen this for D9 to change the truncated length from 50 characters to another number and then update the D7 patch to reflect this (this was what @David_Rothstein proposed originally).

I understand that for D8/9 this was probably important from the UI/UX and mobile friendly point of view, but D7 is in a bit different state now and I think we should decide between 2. or 3. Just for the illustration, if you create a long alias in D7, it is wrapped correctly (if it doesn't contain only characters without delimiters, which should be uncommon scenario), so nothing too disturbing for me there (see the attached image).

Switching to Needs review as this needs to be decided by @mcdruid / @Fabianx.

swirt’s picture

If #3351638: Remove truncation of path alias lands, this issue can likely be closed.

poker10’s picture

Status: Needs review » Postponed

Thanks! Let's postpone this until that one is resolved (either committed or not).

poker10’s picture

Version: 7.x-dev » 8.0.x-dev
Status: Postponed » Fixed
Issue tags: -Needs backport to D7, -Needs reroll

This was committed to D8 on 8.5.2012. And the behavior was "reverted" in D10 today, see: #3351638: Remove truncation of path alias

This means that the current status in D7 (without the patch committed) is the same as in the D10 - aliases are not truncated.

I am going to close this issue as Fixed for D8, based on #52, so that credits are assigned properly. For D7 backport it is a Won't fix (we will not make any change).

Thanks all.

Status: Fixed » Closed (fixed)

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