Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Front end crashing Markdown Notices plugin

Solved by pamtbaau View solution

Started by Michael 4 years ago · 4 replies · 312 views
4 years ago

Had markdown notices installed and working, then I disabled it. When I tried to enable it again, every time I load a page on the front end, I get this error in
user/plugins/markdown-notices/markdown-notices.php:

TXT
Whoops \ Exception \ ErrorException (E_WARNING)
count(): Parameter must be an array or an object that implements Countable

I have tried uninstalling, reinstalling, clearing cache, etc. I just cannot get this error to go away.

4 years ago Solution

@mkovnick, I can only reproduce this error when the setting for level_classes in the following files is not a proper array:

  • user/env/YOURENV/config/plugins/markdown-notices.yaml, or
  • user/config/plugins/markdown-notices.yaml, or
  • user/plugins/markdown-notices/markdown-notices.yaml

Correct array values are:

  • level_classes: [yellow, red, blue, green]
  • YAML
    level_classes: 
    - yellow
    - red
    - blue
    - green
    

    Incorrect values:

  • level_classes:
  • level_classes: 'yellow, red, blue, green'
  • level_classes: yellow, red, blue, green
last edited 01/18/22 by pamtbaau
4 years ago

OK, that got rid of the error, but the highlights are not showing now?

Here is my /user/config/plugins/markdown-notices.yaml file:

YAML
enabled: true
built_in_css: true
base_classes: null
level_classes: [yellow, red, blue, green]

By the way, for some reason when I re-enabled it, level_classes was set to null

4 years ago

OK, I got it working, but I am confused.

I found the file at
user/plugins/markdown-notices/markdown-notices.yaml
and edited that, adding [yellow, red, blue, green] where it had been null, and that stopped it from crashing.

But then I saw I also had the file:
user/config/plugins/markdown-notices.yaml
and that had what appeared to be the correct config:

YAML
enabled: true
built_in_css: true
base_classes: 'notices'
level_classes: [yellow, red, blue, green]

So I copied the same config to user/plugins/markdown-notices/markdown-notices.yaml and everything works as it should.

So one question:
Why would I have both of those files on a fresh install from yesterday? Is this normal? Should I delete one of the paths?

4 years ago

@mkovnick,

There are three locations for the config file of a plugin:

  • user/env/DOMAIN/config/plugins/markdown-notices.yaml
    See Environment Configuration
  • user/config/plugins/markdown-notices.yaml
  • user/plugins/markdown-notices/markdown-notices.yaml
    Never edit this file, but instead copy it into one of above locations.

This is also the order in which Grav searches for a config setting.

Why would I have both of those files on a fresh install from yesterday?

You don't have both files after a fresh install.

  • After an initial install, there is only one config file: user/plugins/markdown-notices/markdown-notices.yaml.
    • After re-install, only this file gets overridden.
  • When using Admin and saving the config, depending on the domain of the server/PC, a file is saved either in:
    • user/env/DOMAIN/config/plugins/markdown-notices.yaml, or
    • user/config/plugins/markdown-notices.yaml

Should I delete one of the paths?

No, one is the original plugin's default config, the other is the altered config. They both have their reason of existence and are each others fallback.

Suggested topics

Topic Participants Replies Views Activity
Support · by Duc , 8 hours ago
1 34 8 hours ago
Support · by Thomas, 1 week ago
3 105 17 hours ago
Support · by Anna, 4 days ago
2 101 2 days ago
Support · by Justin Young, 2 days ago
1 67 2 days ago
Support · by Duc , 1 week ago
2 106 6 days ago