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

Layered metadata element containers not obeying ''ifdef' display templating #1542

Open
Monica-Wood opened this issue Mar 6, 2024 · 7 comments

Comments

@Monica-Wood
Copy link

This might be a tricky one to explain, so I'll do my best.

I have a metadata element that is a container, and within this container there are 2 other containers eg. 'line1', 'line2'. Inside each of the line* containers are the actual metadata elements (in this case a daterange in line1 and text in line2). For clarity I am talking about the 'acqinfo' container that is found in ISAD(G) profile.

When displaying this data using display template (in both providence and pawtucket)

<ifdef code="ca_objects.acqinfo">
    <h6>Acquisition Details</h6>
    <div>
    <ifdef code="ca_objects.acqinfo.acqinfoDate">Date: ^ca_objects.acqinfo.acqinfoDate<br></ifdef>
    ^ca_objects.acqinfo.acqinfoDetail
    </div>
</ifdef>

It will return the 'Acquisition Details' header, even though there is no data in the container.

I edited the database to remove the elements from the intermediate containers 'line1', 'line2' and place them directly under the top container and it started to work as you would expect.

So something is up with the display templating dealing with multi-layered containers.

@kehh
Copy link
Contributor

kehh commented Mar 6, 2024

If you remove the intermediate containers you'll have to also set the correct parent id and I think left and right values as well for child elements for them to play nicely.

@kehh
Copy link
Contributor

kehh commented Mar 6, 2024

rebuild hierarchies for the ca_metadata_elements table if possible

@Monica-Wood
Copy link
Author

I don't want to remove the intermediate containers. The issue is about how the display template isn't working as expected when there are intermediate containers. I only removed them so I could test if this was the reason, as containers without them were displaying correctly.

@collectiveaccess
Copy link
Owner

We will investigate this.

@collectiveaccess
Copy link
Owner

I don't see a problem here, testing on several production systems using current dev/php8 code. When you using the container code in , as you are, if any part of the container outputs anything, even whitespace, it's going to test true and return template content, including your header. I'd make sure there's nothing in that container that's outputting whitespace, and also consider changing the to test on a specific sub-element.

In my tests I used the container code but made sure all sub-elements (which included text fields, lists and dates, as well as intermediate sub-containers) were entirely devoid of content. In those cases the template was suppressed. Adding white space to the text fields triggered the template, which is how it's supposed to work.

If you want whitespace to be ignored in it would certainly be possible to add that option.

@Monica-Wood
Copy link
Author

Definitely no content in it. I delete the container and save so there is nothing showing in that bundle, just the "add acquisition details" plus button. It then doesn't show on the template. BUT it's set to have min of 1 bundle showing, so it pops up again after the save. If you save the record again, not touching that bundle at all, it shows in the template again. It is a container with only 2 other containers. One container holds a date range, the other a text field.
I will test further, but so far it does it on all containers that only have fields in intermediate containers.

@collectiveaccess
Copy link
Owner

When you output the container itself (^ca_objects.acqinfo), even if all of the constituents are blank you should be seeing semicolons (the default delimiter). The behavior for converting a reference to a container to a string for display in a template is to string together all of the sub-values with the delimiter, which defaults to a semicolon. It's the delimiter between the blank values that is triggering the ... at least that's the most likely thing going on. Setting the delimiter to nothing at all should resolve this. Does the template below work for you?

<ifdef code="ca_objects.acqinfo%delimiter=">
    <h6>Acquisition Details</h6>
    <div>
    <ifdef code="ca_objects.acqinfo.acqinfoDate">Date: ^ca_objects.acqinfo.acqinfoDate<br></ifdef>
    ^ca_objects.acqinfo.acqinfoDetail
    </div>
</ifdef>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants