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

Nav:counts throws error if result is 0 #1061

Closed
joakimbording opened this Issue Oct 24, 2016 · 0 comments

Comments

Projects
None yet
2 participants
@joakimbording

joakimbording commented Oct 24, 2016

Expected behaviour

In a folder structure like

Fruits
- Apple
- Banana

{{ nav:counts from="/fruits" }} should return 2
{{ nav:counts from="/fruits/apple" }} should return 0

Actual behaviour

{{ nav:counts from="/fruits" }} returns 2
{{ nav:counts from="/fruits/apple" }} throws an error:

FatalThrowableError in NavTags.php line 66:
Call to a member function count() on boolean
in NavTags.php line 66
at NavTags->count()
at call_user_func(array(object(NavTags), 'count')) in Engine.php line 162

Suggestion on fix in NavTags.php:

/**
     * The {{ nav:count }} tag
     *
     * @return  string
     */
    public function count()
    {
        $this->factory = new TreeFactory($this->getParams());

        $tree = $this->factory->create();
        if(!$tree) return 0;
        return $tree->count();
    }

Steps to reproduce

Server configuration

Operating system:
OS X, MAMP
Web server:
Apache
PHP version:
7.0.10
Statamic version:
2.1.15
Updated from an older Statamic or fresh install:
Updated from 2.1
List of installed addons:
None

Logs

If any logs (browser, server, or Statamic) are appropriate...

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