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

{{ get_values }} breaks if no filters are used #657

Closed
curtisblackwell opened this Issue May 2, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@curtisblackwell

curtisblackwell commented May 2, 2016

Steps to reproduce

  1. Use {{ get_values:var from="/my-page" }} w/o filters.

Expected behaviour

All values within the var array should be returned.

Actual behaviour

Error: Undefined variable: match

Server configuration

Statamic version: 2.0.3

@curtisblackwell

This comment has been minimized.

Show comment
Hide comment
@curtisblackwell

curtisblackwell May 2, 2016

Here's how I hotfixed it:

if ($filters) {
    $values = array_values(array_filter($field_data, function ($i) use ($filters) {
        foreach ($filters as $key => $val) {
            $match = array_get($i, $key) == $val;

            if (! $match) {
                break;
            }
        }

        return $match;
    }));
} else {
    $values = $field_data;
}

curtisblackwell commented May 2, 2016

Here's how I hotfixed it:

if ($filters) {
    $values = array_values(array_filter($field_data, function ($i) use ($filters) {
        foreach ($filters as $key => $val) {
            $match = array_get($i, $key) == $val;

            if (! $match) {
                break;
            }
        }

        return $match;
    }));
} else {
    $values = $field_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment