Skip to content
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

Error when defaultSearchTermOptions are configured #30

Closed
juresrpcic opened this issue Dec 8, 2017 · 5 comments
Closed

Error when defaultSearchTermOptions are configured #30

juresrpcic opened this issue Dec 8, 2017 · 5 comments
Labels

Comments

@juresrpcic
Copy link

Description

I installed the latest version (2.0.1) successfully - no more issues with composer requiring dev-craft-3 like yesterday. When I tried installing the plugin, I got an error:

PHP Notice – yii\base\ErrorException
Array to string conversion
vendor\verbb\cp-nav\src\models\Navigation.php
(error on line 158) $url = str_replace('{' . $key . '}', $value, $url);

I can go back and the plugin appears installed, but it's not functional - the settings page only shows the layouts dropdown and no switches.

After some research, I discovered that a Craft config setting is causing this - in general.php, I have this setting under '*':

'defaultSearchTermOptions' => [
	'subLeft' => true,
	'subRight' => true,
],

If I disable that part of the config, the plugin works again and doesn't cause the issue on install.

Steps to reproduce

  1. Install plugin - composer require verbb/cp-nav
  2. Install plugin through CP, get error

Additional info

  • Plugin version: 2.0.1
  • Craft version: 3.0.0-RC1
@juresrpcic
Copy link
Author

It seems any array used in general.php causes this issue - the same happens if I have this under the 'dev' key:

'environmentVariables' => [
	'baseUrl' => 'http://test-website.local/',
	'basePath' => 'C:\web\test-website\public\\',
],

@svenjungnickel
Copy link

Hey @juresrpcic. Thanks for sending that issue. I will look into that and keep you posted.

svenjungnickel pushed a commit that referenced this issue Dec 11, 2017
@svenjungnickel
Copy link

@juresrpcic the concept of environment variables don't exists anymore in craft 3.
See . Hence the array for environmentVariables is superfluous. But that doesn't mean there can't be other config variables defined as an array. They're just ignored by CP Nav.

I uploaded a fix to the latest craft-3 branch. Can you install and test it please? To install the latest dev version you have to set the dev-craft-3 branch (again): composer require verbb/cp-nav:dev-craft-3.

@juresrpcic
Copy link
Author

@svenjungnickel Thanks for the update! I tested this again (with an array for search options in general.php) and it's no longer reporting any error (using dev-craft-3 branch).

Re environmentVariables - I am aware this is not a thing anymore in Craft 3 - I just wanted to test with another array in general.php and had that lying around...

@svenjungnickel
Copy link

@juresrpcic thanks you tested that. I just tagged a new release. You should be able to install the plugin without adding the dev branch now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants