I created a content type called "Products"

I then added an image field and gave the File Directory a path of [current-page:title]

I then created a node (from the products content type) and gave it a title "Towel"

I uploaded a picture, but on my directory, the image got uploaded to drupal/sites/default/files instead of drupal/sites/default/files/towel

I then tried the dev version and same result.

I was using Drupal 8.0.5 so I decided to try it on the latest Drupal 8.1.0 and on a fresh install.

When I did using Alpha, my file got uploaded to drupal/sites/default/Create Products (which is weird, was not expecting my content type here).

I then decided to try the dev version, and it did not create a folder, was uploading to drupal/sites/default/files (again like on 8.0.5)

I then decided to switch back to the Alpha version, and now is not even created the weird Create Products folder. It's uploading to drupal/sites/default/

Something weird is going on here...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Camster created an issue. See original summary.

No Sssweat’s picture

Issue summary: View changes
No Sssweat’s picture

Issue summary: View changes
NetNerdy’s picture

Version: 8.x-1.0-alpha2 » 8.x-1.x-dev
Component: Token Actions » Code
Category: Bug report » Task
FileSize
43.63 KB
82.18 KB
73.31 KB

same problem and a little bit confusing...

on "add content" or "creation page" runs the token "current-page:title" ...on the "edit page" doe's it nothing

...see screenshots attached

Berdir’s picture

Status: Active » Postponed (maintainer needs more info)

This is likely a duplicate of #2675738: "Array to string conversion in Drupal" in Forum. If you check our log, you probably have similar errors as posted there.

No Sssweat’s picture

FileSize
378.94 KB

@Berdir

I was able to work around this bug by using https://www.drupal.org/project/filefield_paths module. This module gives you Node tokens which did the trick.

I used the [node:title] token instead of [current-page:title]

img

webflo’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
689 bytes

I think the result of the title resolver service should be processed by token_render_array_value. TitleResolverInterface::getTitle returns array, string or null.

Berdir’s picture

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

Nice, a test would be great.

Given #2675738: "Array to string conversion in Drupal" in Forum, I think we could test it by placing a block with the current page title token and visiting the forum page.

hussainweb’s picture

I repurposed an existing route in one of the test modules to return a title as an array.

The last submitted patch, 9: current_page_title_-2714257-9-tests-only.patch, failed testing.

The last submitted patch, 9: current_page_title_-2714257-9-tests-only.patch, failed testing.

Berdir’s picture

Status: Needs review » Needs work

Nice, works for me. But lets add a comment to explain why we're doing this (could be as part of the currently missing docblock for that method) and also some kind of assert in a test, the one that already visits that page works for me.

hussainweb’s picture

I added the comments and assert. Since the patch is small, I hope interdiff is not required. :)

Status: Needs review » Needs work

The last submitted patch, 13: current_page_title_-2714257-13.patch, failed testing.

The last submitted patch, 13: current_page_title_-2714257-13.patch, failed testing.

hussainweb’s picture

Assigned: Unassigned » hussainweb

The problem is that the title is 'Available Tokens | Drupal' instead of just 'Available Tokens'. I will work on this later today.

hussainweb’s picture

Assigned: hussainweb » Unassigned
Status: Needs work » Needs review
FileSize
3.51 KB

I am not sure if it is good to assert 'Available Tokens | Drupal' but here goes.

  • Berdir committed 6f85bcb on 8.x-1.x authored by hussainweb
    Issue #2714257 by hussainweb, webflo, NerdyCrowd, Camster: [current-page...
Berdir’s picture

Title: [current-page:title] not working properly with Image File Directory » [current-page:title] not working properly on pages with a render array as title
Status: Needs review » Fixed
Issue tags: -Needs tests

Yeah, that's fine. Thanks!

Status: Fixed » Closed (fixed)

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