core icon indicating copy to clipboard operation
core copied to clipboard

Containers: Cannot print properly image/file fields of contents added to container

Open joseorsini opened this issue 9 years ago • 3 comments

If a content type has 2 or more image/file fields, there is a problem with how contents are printed once they're added to a container.

Expected Behavior

Values of fields should always be displayed on frontend pages, according to the container's code.

Current Behavior

There is an apparent 'leak' of image/file fields when there are multiple contents added to a container and the parent content types have 2 or more Image/File fields. If the first content on top of the container have valid values on these fields, it doesn't matter if all remaining contents have these fields populated or not. 1+N Image/file fields will repeat the same value from the first content.

Possible Solution

Check how contents are validated and add support on Java logic for multiple image/file fields if missing.

Known Workarounds

none.

Steps to Reproduce (for bugs)

  1. Create a test container for Event contents. Set Max contentlets value to 5 and use this as container's code
$!{title}
<br>
<br>
    <br>
    sp1 $!{image}
    $!{imageImageIdentifier}
    <br>
#if ($UtilMethods.isSet(${imageImageURI}))
   <img src="$!{imageImageURI}" alt="$!{imageImageTitle}"  />
#end

    <br>
    sp2 $!{file}
$!{fileFileIdentifier}
<br>

#if ($UtilMethods.isSet(${fileFileURI}))
   <img src="$!{fileFileURI}" alt="$!{fileFileTitle}"  />
#end
  1. Create a template and parse the newly created container.

  2. Create a page with the newly created container.

  3. Add 3 Event containers.

    • Test Event 001 havs its Image/File fields populated. screen shot 2017-05-18 at 5 20 03 pm

    • Test Event 002 has only one Image/File field populated: screen shot 2017-05-18 at 5 20 17 pm

  • Test Event 003 has only one Image/File field populated screen shot 2017-05-18 at 5 20 34 pm
  1. If you look at the page, you'll see that the File Image is repeated across all other contents, despite these ones are NOT part of the actual content being printed on the Velocity Context.
  • Test Event 001 - Live Mode. It shows its two Image/File fields as expected. screen shot 2017-05-18 at 5 29 35 pm

  • Test Event 002 - Live mode. It shows its first Image/File field, but it prints the File one from 1st content screen shot 2017-05-18 at 5 29 40 pm

e255d31b3b60.png">

  • Test Event 003 - Live mode. It shows its first Image/File field, but it prints the File one from 1st content as well screen shot 2017-05-18 at 5 29 53 pm

Context

Reported by customer: https://my.dotcms.com/tickets/detail.dot?id=decad80d-95f9-4d59-9671-2e3b82f7475b.

Your Environment

  • dotCMS 4.x
  • Any OS/Browser.
  • Tomcat 8.0.18.
  • Java 8u121.
  • Postgres DB.

joseorsini avatar May 18 '17 21:05 joseorsini

PR for master repo: https://github.com/dotCMS/core/pull/11655

joseorsini avatar May 19 '17 17:05 joseorsini

PRs for removing validation: https://github.com/dotCMS/core/pull/12011, https://github.com/dotCMS/core/pull/12014

dsilvam avatar Jun 28 '17 21:06 dsilvam

Passed QA Followed steps to reproduce. I was able to see the contents being printed properly on each test event ( Test Event 001, Test Event 002 and Test Event 003)

Tested locally using the following environments: Upgrade from dotcms_3.6 with client dataset (db and assets) to master branch / commit 166c46f5c177b8b155fb7b2ceb9072f25f68432d MacOSx 10.10 / Postgres 9.3.7 / Chrome v54.0.2840.98 / Tomcat 8 / Java 8

shaydotcms avatar Jul 14 '17 21:07 shaydotcms