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_content throws error when `from` param can't be found #1598

Closed
aryehraber opened this Issue Sep 14, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@aryehraber

aryehraber commented Sep 14, 2017

Expected behaviour

When a page can't be found using the from param, get_content should fail silently just like when the fields/variables between the tag pair can't be found.

Actual behaviour

A fatal error is thrown:

FatalThrowableError in GetContentTags.php line 45:
Call to a member function in() on null

Steps to reproduce

This snippet will fail when segment_1 isn't an actual standalone page:

{{ get_content from="/{segment_1}" }}
    // Do stuff and things
{{ /get_content }}

Temp. solution

$this->collection = collect_content(
    Helper::explodeOptions($locations)
)->map(function ($from) use ($locale) {
    return ($content = $this->getContent($from))
        ? $content->in($locale) : null;
})->filter();
@alehandrof

This comment has been minimized.

alehandrof commented Aug 31, 2018

Relatedly, it would be helpful if there's a no_results variable so that I can check in the template if it's failed and do appropriate things. Shall I open a separate FR for this?

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