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

PHP errors and unexpected results when using File Grid field from within Fluid field #74

Closed
MatthewJLewis opened this Issue Jan 1, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@MatthewJLewis
Copy link

MatthewJLewis commented Jan 1, 2019

I have created a File Grid field called "image" and have added rows for Width, Alignment, Caption, etc. I then associated that field with a Fluid field called "blocks."

Here is my full template code:

{exp:channel:entries channel="blog" limit="1" dynamic="no" url_title="{segment_2}"}
	{blocks}
		{blocks:image}
			{content}
				<ul>
					<li>{content:width}</li>
					<li>{content:align}</li>
					<li>{content:caption}</li>
				</ul>
			{/content}
		{/blocks:image}
	{/blocks}
{/exp:channel:entries}

When I load up the template, I get a completely blank page. Just one blank line in the page source.

Here's where it gets odd: If I remove the content: from the list items and instead just use {width}, {align}, etc., then the correct values are shown but I also get the following PHP errors:

Notice
Undefined offset: 5
ee/legacy/libraries/Grid_parser.php, line 146

Severity: E_NOTICE
Notice
Undefined offset: 5
ee/legacy/libraries/Grid_parser.php, line 420

Severity: E_NOTICE
Warning
Cannot modify header information - headers already sent by (output started at ee/legacy/core/Exceptions.php:120)
ee/EllisLab/ExpressionEngine/Boot/boot.common.php, line 488

Severity: E_WARNING

I can get the file location by using {file} but I have yet to figure out how to get the file's metadata, such as credit, etc. So although I'll probably be able to get a workable template out of this, I won't be able to get full functionality (and the credit field from the metadata is important for the site I'm developing).

Running EE 5.1.1 on PHP 7.2.11.

@kevincupp

This comment has been minimized.

Copy link
Contributor

kevincupp commented Jan 2, 2019

Sorry, @MatthewJLewis, I can reproduce on my end. Here's a patch you get you going again:

--- a/system/ee/EllisLab/Addons/fluid_field/Service/Tag.php
+++ b/system/ee/EllisLab/Addons/fluid_field/Service/Tag.php
@@ -162,7 +162,7 @@ class Tag {
                {
                        list($modifier, $content, $params, $chunk) = $chk_data;

-                       if ($field->getType() == 'grid')
+                       if ($field->getType() == 'grid' || $field->getType() == 'file_grid')
                        {
                                ee()->load->library('grid_parser');
                                ee()->grid_parser->grid_field_names[$field->getId()][$field->getItem('fluid_field_data_id')] = $field->getName();

As for how to access metadata, it should work as normal:

{blocks}
    {blocks:image} <!-- Assumed File Grid -->
        {content}
            {content:file}
                {credit}
            {/content:file}
        {/content}
    {/blocks:image}
{/blocks}

@kevincupp kevincupp closed this in fa75c83 Jan 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment