Giter Club home page Giter Club logo

cp-nav's Introduction

Control Panel Nav icon

Control Panel Nav for Craft CMS

Control Panel Nav is a Craft CMS plugin to help manage your Control Panel navigation. Take control over your Craft CMS control panel navigation with CP Nav. Rename, reorder, hide and show menu items in the control panel. You can even add your own custom menu items for external links, or commonly used URLs within Craft. Divider menu items can also be added to logically group menu items into sections.

Features

  • Modify the main sidebar navigation in the Craft control panel.
  • Rename, reorder, remove any existing navigation items - including plugins and modules.
  • Full support for nesting items up to 2 levels deep.
  • Change the behaviour of subnav items:
    • Only open subnav items when the parent page is active (Craft default behaviour).
    • Always have subnav items open and visible.
    • Add a toggle next to each parent menu item to show/hide the subnav items. Will also remember the state!
  • Add new custom URLs. Great for documentation, external links or nested pages.
  • Add divider menu items. Great for grouping pages together or providing a logical gap between groups of different pages.
  • Manage icons of menu items. Choose from existing Craft icons, or upload your own assets.
  • Support for layouts to manage multiple navigations depending on user groups.
  • Project Config support, so your navigations are the same across environments.
  • Full support for your existing user permissions. Menu items for Craft and plugins will only be shown if the users is permitted to view them.
  • Unlimited use, free forever.

Documentation

Visit the Control Panel Nav Plugin page for all documentation, guides, pricing and developer resources.

Support

Get in touch with us via the Control Panel Nav Support page or by creating a Github issue

Sponsor

Control Panel Nav is licensed under the MIT license, meaning it will always be free and open source – we love free stuff! If you'd like to show your support to the plugin regardless, Sponsor development.

cp-nav's People

Contributors

ackwell avatar brandonkelly avatar crswll avatar deling avatar dennisfrank avatar engram-design avatar erikswan avatar fthues avatar jamesmacwhite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cp-nav's Issues

Error when all tabs removed

If you have no tabs enabled, you can trigger an error by going to /admin.

Expected behavior:

  • Be forced to view the standard Dashboard, even though it's disabled.

Steps to reproduce:

  1. Disable all tabs
  2. Go to /admin
  3. Witness error message

error

Errors on latest Craft CMS

screenshot 2016-03-10 10 18 15

This is solved now, cpnav.js had to be CPNav.js. Same for the css file.

  • I had no other member groups, seems you need to have at least one.

Can't rename existing Nav links

Trying to rename existing navigation links. This is what I got from the chrome console:

CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'newWindow' cannot be null. The SQL statement executed was: UPDATE `cpnav_navs` SET `enabled`=:yp0, `order`=:yp1, `manualNav`=:yp2, `newWindow`=:yp3, `id`=:yp4, `layoutId`=:yp5, `handle`=:yp6, `prevLabel`=:yp7, `currLabel`=:yp8, `prevUrl`=:yp9, `url`=:yp10, `icon`=:yp11, `customIcon`=:yp12, `dateCreated`=:yp13, `dateUpdated`=:yp14, `uid`=:yp15 WHERE `cpnav_navs`.`id`=6. Bound with :yp0=1, :yp1=5, :yp2=0, :yp3=NULL, :yp4=6, :yp5=1, :yp6='seomatic', :yp7='SEOmatic', :yp8='SEO', :yp9='seomatic', :yp10='seomatic', :yp11='iconSvg-seomatic', :yp12='', :yp13='2016-09-27 12:26:00', :yp14='2016-09-27 12:33:53', :yp15='200848b4-5e61-4054-b047-f8ac8f6f01b0' (/vagrant/craft/app/framework/db/CDbCommand.php:358)

#0 /vagrant/craft/app/framework/db/ar/CActiveRecord.php(1754): CDbCommand->execute()
#1 /vagrant/craft/app/framework/db/ar/CActiveRecord.php(1128): CActiveRecord->updateByPk('6', Array)
#2 /vagrant/craft/app/framework/db/ar/CActiveRecord.php(810): CActiveRecord->update(NULL)
#3 /vagrant/craft/plugins/cpnav/services/CpNav_NavService.php(64): CActiveRecord->save(false)
#4 /vagrant/craft/plugins/cpnav/controllers/CpNav_NavController.php(117): Craft\CpNav_NavService->save(Object(Craft\CpNav_NavModel))
#5 /vagrant/craft/app/framework/web/actions/CInlineAction.php(49): Craft\CpNav_NavController->actionSave()
#6 /vagrant/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(Array)
#7 /vagrant/craft/app/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))
#8 /vagrant/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#9 /vagrant/craft/app/framework/web/CWebApplication.php(282): CController->run('save')
#10 /vagrant/craft/app/etc/web/WebApp.php(818): CWebApplication->runController('cpNav/nav/save')
#11 /vagrant/craft/app/etc/web/WebApp.php(288): Craft\WebApp->_processActionRequest()
#12 /vagrant/craft/app/framework/base/CApplication.php(185): Craft\WebApp->processRequest()
#13 /vagrant/craft/app/index.php(62): CApplication->run()
#14 /vagrant/public/index.php(32): require_once('/vagrant/craft/...')
#15 {main}

Nav item doesn't display "sel" class (Craft 3)

Description

Sidebar nav items no longer have class="sel" when they're active, so I'm not able to see at a glance which section of the control panel I'm currently in.

Additional info

  • Plugin version: 2.0.3
  • Craft version: 3.0.0-RC14

Project Config support

It would be convenient to be able to export and import layouts, like you can export/import fields with Field Manager. Of course, some urls might not exist in the new site, but I think just a general warning when importing would be okay for that, at least as a MVP.

I just configured a sweet layout on my dev site and thought that project.yaml would push it to staging, but I guess it's in the database instead.

Picture uploaded into asset volume not shown

Description

It seems any picture (.svg) uploaded in a local asset volume doesn't work. Only files uploaded into "temporary uploads" actually appear in the menu. All other images are just shown as the default "circle with a letter".

In the CMS, the picture is displayed correctly.

I do have other asset volumes defined (Amazon S3) but I'm uploading the icon (.svg) in a second local asset volume.

View screenshot

Steps to reproduce

  1. Add new menu item
  2. Choose icon and upload in an existing local asset folder

Additional info

  • Plugin version: 2.0.8
  • Craft version: 3.0.18

Getting Twig runtime error: Variable "layouts" does not exist when in dev mode

Description

After installing I went into the plugins menu and clicked on the plugin and I get this error when in dev mode

Twig Runtime Error
Variable "layouts" does not exist.
in <sitePath>/vendor/verbb/cp-nav/src/templates/index.html

Steps to reproduce

  1. Put site into dev mode
  2. Install plugin
  3. Click on plugin in settings menu

Additional info

  • Plugin version: 2.0.9
  • Craft version: 3.0.32 (Pro, dev mode)

I am also having a similar issue (variable not existing) with your field-manager plugin, I will wait to see the resolution of this one as they will likely be linked.

Update

This only happens in dev mode and seems to effect all Verbb plugins

Thanks!

Creating a new layout gives an error.

Latest Craft Release 3.0.1
Latest CP Nav

Console output:

{error: "Calling unknown method: craft\elements\db\UserQuery::client()"}
error: "Calling unknown method: craft\elements\db\UserQuery::client()"

How do I assign layouts to a user?

I'm using Craft Pro 2.6.2968, with the latest version of this plugin (just downloaded it today). I am able to create new Layouts and set which CP items are visible etc... but I cannot see anywhere that allows me to "connect" a particular layout to a particular user. (I tried naming the layout to both the group and the username of the user that I want to assign it to, but it doesn't do anything -- I still always see the default layout items in my sidebar).

Thanks -- great plugin btw, really appreciate it!

Error when defaultSearchTermOptions are configured

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

Unknown error occurred when performing any actions

I've used this plugin on Craft 2 and it's great, but we're having issues using with the Craft 3 beta.

Installed using composer and activated, however getting: An unknown error occurred.

This happens when trying to do anything.

Lost icons

Description

When Control Panel Nav is enabled, the default Craft icons in the left menu bar (dashboard, categories, users, utilities,...) become circles with letters.

Additional info

  • Plugin version: 2.0.7
  • Craft version: 3.0.9

Manual link - Ability to "Open in new window"

I see on your roadmap that you plan to give the option for manual links to "Open in a new window"... Just wanted to let you know that this has my vote, I could see this feature being quite useful! :)

Select SVG from Craft defaults (feature request)

I like the improved interface in 2.0.9!

Default icons are working for me again in new and regenerated menus. 👍

Something that's tricky/time consuming for me is finding the right SVG icons for my custom links. Some ideas:

  • Somehow allow the user to select from Craft's default SVG icons (in addition to uploading a custom one)
  • At least link to where the Craft icons can be downloaded, or how they can be referenced

Override the selected item class

It'd be nice to have the ability to override the selected item (a.sel) when a custom menu is active.

For example, if you create a link to that goes to Settings > Fields, the "Settings" tab is always active instead of the "Fields" link. I don't know if this is possible but just thought I'd add a feature request.

Control Panel Nav Removes Item

Description

When adding a url in entries/leadPages to the nav it will display properly until you move anywhere besides the navigate tab

screen shot 2018-11-13 at 11 19 46 am
screen shot 2018-11-13 at 11 20 01 am

Steps to reproduce

  1. Create item entries/leadPages
  2. Move away from the navigate tab

Additional info

  • Plugin version: 2.0.9
  • Craft version: 3.0.31

500 Error on rename

Hi guys, I'm getting an Integrity constraint violation when trying to rename a menu item in Craft Pro 2.4.2702. Full response here:

CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'newWindow' cannot be null. The SQL statement executed was: UPDATE `cpnav_navs` SET `enabled `=:yp0, `order`=:yp1, `manualNav`=:yp2, `newWindow`=:yp3, `id`=:yp4, `layoutId`=:yp5, `handle`=:yp6, `prevLabel`=:yp7, `currLabel`=:yp8, `prevUrl`=:yp9, `url`=:yp10, `dateCreated`=:yp11, `dateUpdated` =:yp12, `uid`=:yp13 WHERE `cpnav_navs`.`id`=5. Bound with :yp0=1, :yp1=4, :yp2=0, :yp3=NULL, :yp4=5, :yp5=1, :yp6='charge', :yp7='Charge', :yp8='Charge', :yp9='charge', :yp10='charge', :yp11='2015-10-31 11:28:34', :yp12='2015-10-31 11:31:39', :yp13='651f9529-a8d6-421b-9bf6-4d42c510cbc1' (/Users/James/Sites /craft.dev/craft/app/framework/db/CDbCommand.php:358)

#0 /Users/James/Sites/craft.dev/craft/app/framework/db/ar/CActiveRecord.php(1754): CDbCommand->execute()
#1 /Users/James/Sites/craft.dev/craft/app/framework/db/ar/CActiveRecord.php(1128): CActiveRecord-

updateByPk('5', Array)

2 /Users/James/Sites/craft.dev/craft/app/framework/db/ar/CActiveRecord.php(810): CActiveRecord-

update(NULL)

3 /Users/James/Sites/craft.dev/craft/plugins/cpnav/services/CpNav_NavService.php(152): CActiveRecord-

save()

4 /Users/James/Sites/craft.dev/craft/plugins/cpnav/controllers/CpNavController.php(136)

: Craft\CpNav_NavService->saveNav(Object(Craft\CpNav_NavModel))

5 /Users/James/Sites/craft.dev/craft/app/framework/web/actions/CInlineAction.php(49): Craft

\CpNavController->actionSaveNav()

6 /Users/James/Sites/craft.dev/craft/app/framework/web/CController.php(308): CInlineAction-

runWithParams(Array)

7 /Users/James/Sites/craft.dev/craft/app/framework/web/CController.php(286): CController-

runAction(Object(CInlineAction))

8 /Users/James/Sites/craft.dev/craft/app/framework/web/CController.php(265): CController-

runActionWithFilters(Object(CInlineAction), Array)

9 /Users/James/Sites/craft.dev/craft/app/framework/web/CWebApplication.php(282): CController-

run('saveNav')

10 /Users/James/Sites/craft.dev/craft/app/etc/web/WebApp.php(805): CWebApplication->runController

('cpNav/saveNav')

11 /Users/James/Sites/craft.dev/craft/app/etc/web/WebApp.php(275): Craft\WebApp->_processActionRequest

()

12 /Users/James/Sites/craft.dev/craft/app/framework/base/CApplication.php(184): Craft\WebApp-

processRequest()

13 /Users/James/Sites/craft.dev/craft/app/index.php(62): CApplication->run()

14 /Users/James/Sites/craft.dev/htdocs/index.php(19): require_once('/Users/James/Si...'

)

15 {main}

Any ideas?

[Bug] Renaming Globals

Discovered an issue yesterday which I think needs fixing in CPNav rather than somewhere else. I created a global set called "Social Networks" to contain Facebook and Twitter links for the site. Handle name was socialNetworks.

Later, I renamed that global set handle to 'social'. In Craft, when you visit the Globals panel, the URL you get sent to is automatically set to the handle of the first global field set in use i.e. http://craft.dev/admin/globals/camelCase.

When I renamed the global field set, CPNav still tried to send me to http://store.craft.dev/castle/globals/socialNetworks, but it should be sending me to http://store.craft.dev/castle/globals/social. Uninstalling and reinstalling the plugin fixed the error. Is there a way to update this dynamically?

"POST param “permissions” doesn’t exist." when attempting to add new layout.

Hey there! I love the plugin, but I am having some difficulty.

When I attempt to add a new layout, I press the + New layout button, fill in a name, and press the Create button. Then, Craft reports An unknown error occurred. and the console reports POST param “permissions” doesn’t exist. on the attempt to post to /admin/actions/cpNav/layout/new.

When I investigate the request, I do see that the required permissions key is missing, leaving only name=test&id=. Investigating the plugin's code, it certainly appears that on line 55 of CpNav_LayoutController.php the key is required by means of getRequiredPost().

I'm using the newest version, and any help would be appreciated. Thanks!

Handling user-specific layouts

While it's great to be able to set the CP navigation globally, the real mission is to have it defined on a per-user basis. This means that you could have a layout for yourself (Admin), your client, other admins, regular members, etc.

But defining a nav layout per-user is quite tedious, instead it'd be better to group them somehow. While initially I wanted to hook this up with User Groups, its tricky as a user can belong to multiple groups, which just wouldn't work when trying to figure out what layout to use. Not to mention these only exist on Craft Pro.

Instead, I've gone down the path of allowing Layouts to be created. You can then edit your nav items for a layout, and assign which users will see this layout.

The idea behind this is you'll define a Default layout, which newly registered users will see, another for your client, and another for admin, etc. This will mean you don't have to manually assign a layout to a user when they are created - that would suck.

Love to hear how people would prefer this to be specified! Any other ideas?

screen shot 2015-03-15 at 11 48 30 pm

SVG icons in header nav lost after Craft update to 3.0.7

Posted this originally at Craft github, but it seems to be a CP nav issue: After running Composer update to Craft 3.0.7 the icons in the dark blue area went missing. (Others were still present.)

Disabling the CP nav plugin brings back the icons so I am posting this here. Thank you vey much for checking that.

SVG icons not reproduced correctly

Description

Here's 2 screenshots, with and without the plugin activated. Customer Lists is your own Wishlist plugin.

If I regenerate the navigation, it fixes the 2 icons, but as soon as I switch page, the issue comes back.

2019-06-13 11_47_50-Plugins - Great Boardgames
2019-06-13 11_48_21-Plugins - Great Boardgames

Additional info

  • Plugin version: 2.0.9
  • Craft version: Craft Pro 3.1.29

yii\base\ErrorException: Array to string conversion at install

Im getting an Array to String conversion error at install.
But the plugin did install correctly. Uninstall works ok.

I have two sites (2 languages).
'siteUrl' => [
'chilliEnglish' => '//xxxxx.be',
'chilliNederlands' => '//xxxxxx.be/nl' ],

  • Plugin version: 2.0.2
  • Craft version: Craft 3 RC5

Trace:

yii\base\ErrorException: Array to string conversion in /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/verbb/cp-nav/src/models/Navigation.php:164 Stack trace: #0 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/craftcms/cms/src/web/ErrorHandler.php(84): yii\base\ErrorHandler->handleError(8, 'Array to string...', '/data/sites/web...', 164) #1 [internal function]: craft\web\ErrorHandler->handleError(8, 'Array to string...', '/data/sites/web...', 164, Array) #2 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/verbb/cp-nav/src/models/Navigation.php(164): str_replace('{siteUrl}', Array, '') #3 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/verbb/cp-nav/src/services/CpNavService.php(198): verbb\cpnav\models\Navigation->__construct() #4 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/verbb/cp-nav/src/services/CpNavService.php(161): verbb\cpnav\services\CpNavService->_prepareNavModel(Array) #5 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/verbb/cp-nav/src/services/CpNavService.php(118): verbb\cpnav\services\CpNavService->regenerateNav(1, NULL, Array) #6 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/verbb/cp-nav/src/CpNav.php(72): verbb\cpnav\services\CpNavService->setupDefaults() #7 [internal function]: verbb\cpnav\CpNav->verbb\cpnav\{closure}(Object(craft\events\PluginEvent)) #8 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/yiisoft/yii2/base/Event.php(221): call_user_func(Object(Closure), Object(craft\events\PluginEvent)) #9 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/yiisoft/yii2/base/Component.php(565): yii\base\Event::trigger('craft\\services\\...', 'afterInstallPlu...', Object(craft\events\PluginEvent)) #10 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/craftcms/cms/src/services/Plugins.php(480): yii\base\Component->trigger('afterInstallPlu...', Object(craft\events\PluginEvent)) #11 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/craftcms/cms/src/controllers/PluginsController.php(49): craft\services\Plugins->installPlugin('cp-nav') #12 [internal function]: craft\controllers\PluginsController->actionInstallPlugin() #13 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array) #14 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array) #15 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/craftcms/cms/src/web/Controller.php(80): yii\base\Controller->runAction('install-plugin', Array) #16 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('install-plugin', Array) #17 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/craftcms/cms/src/web/Application.php(243): yii\base\Module->runAction('plugins/install...', Array) #18 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/craftcms/cms/src/web/Application.php(421): craft\web\Application->runAction('plugins/install...', Array) #19 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/craftcms/cms/src/web/Application.php(203): craft\web\Application->_processActionRequest(Object(craft\web\Request)) #20 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request)) #21 /data/sites/web/craftstart3-chillibe/checkout/master/6076e45d17611d536412ad56f5e2eb56b317af99/www/index.php(23): yii\base\Application->run() #22 {main}

{siteUrl} support

Sorry for blowing up your Github issues... :)

It would be great if the URL supported {siteUrl} to reference front-end pages. This is crucial for multi-environment setups.

example

Display issue - conflicting with Architect Plugin?

Description

Getting some funky characters in my side bar whenever I turn this plugin on whilst having Architect enabled (v.2.2.8)

screen shot 2018-04-11 at 15 23 39

Also tried removing the custom svg icons from the new entries in the sidenav to see if it was those messing it up, and makes no difference either.

Steps to reproduce

  1. Install CP Nav
  2. Turn CP Nav on
  3. Install Architect
  4. Turn Architect on

Additional info

  • CP Nav Plugin version: 2.0.4
  • Craft version: 3.0.2

Add composer.json for package management and publish on Packagist

I use a workflow for developing my Craft projects that makes heavy use of package management and automation for deployment (using Git post-receive hooks and Gulp). For managing some of the other dependencies that my project relies on (mostly on the front end, things like normalize.css, jQuery, SASS, etc.) I use existing package managers liked npm, bundler, and bower.

This allows me to maintain a git repository for the project with only source code committed and simply do a git push production at which point the workflow I have set up will automatically pull in any dependencies for the project and build everything (compile SASS, minimize JS, etc.). It would be very useful to have plugins support this workflow so that I don't have to manually check out a copy of the plugin and keep it up to date - instead I can just specify that I require this plugin and that will happen automatically.

PHP has the Composer package manager, and Brad Bell has hinted that Craft will likely support installation in this manner in a future release of Craft.

It would be great to see this plugin add a composer.json file and be published on Packagist. That way the above workflow would be supported, and users of the plugin can simply add a composer.json file of their own in their project directory and specify CPNav as a dependency:

{
    "require": {
        "engram-design/cpnav": "~1.6"
    }
}

And then upon deployment pull in the plugin: composer install

Here is a good starting point for the composer.json file that I've put together. It makes use of the Composer installers package to automatically install the plugin to the correct Craft directory:

{
    "name": "engram-design/cpnav",
    "type": "craft-plugin",
    "description": "A Craft CMS plugin to help manage your Control Panel navigation.",
    "keywords": ["craft","plugin", "cp", "navigation"],
    "homepage": "https://github.com/engram-design/CPNav",
    "license": "MIT",
    "authors": [
        {
            "name": "Josh Crawford",
            "email": "[email protected]",
            "homepage": "http://engramdesign.com.au/",
            "role": "Developer"
        }
    ],
    "require": {
        "composer/installers": "~1.0"
    } 
}

Then, to support proper versioning, you would need to tag appropriate commits in this repository to designate plugin releases. Packagist will crawl the repo and automatically make these specific commits available as versions accessible via the "require" syntax shown above.

This workflow should be standard for Craft plugins in my opinion and probably will be once Craft itself is available as a Composer package on Packagist (hopefully soon—once this happens you would then specify the required Craft version in the require object in the composer.json file).

If you would be willing to do this it would be awesome and help with promoting a sane development workflow in the Craft community.

Thanks!

Note for anyone else who want's this type of functionality now:
it can be replicated using Git submodules, which is what I'm currently using to avoid having to commit a working copy of CPNav into my project repo, but it's a bit hacky and proper Composer support would be better.

Manual link not being added

First of all, let me say thank you!! This plugin is brilliant. I'd had the thought to build something similar, but you've far surpassed anything that I would have put together. :)

Here's the bug I'm hitting...

As a test, I tried to create a new external link. For the label, I used "Peanut Butter", and for the URL, I used "http://www.jif.com/". I clicked the button, it said "Menu item added", but it didn't actually add the menu item. I peeked into the database, and it doesn't look like the data was added to the cpnav_navs table.

I've got a couple other minor feedback notes, but I'll open those up as separate tickets. Thanks! :)

Custom Icons Not Working

Description

Craft 3. I have selected custom icons for my CP Nav items, but only seeing the placeholder letters. This works correctly in the C2 version with the same icon files.

Steps to reproduce

  1. Create a CP Nav item
    2.Add a custom SVG icon

Additional info

  • Plugin version: 2.0.3
  • Craft version: 3.0.0-RC10.1

CP nav randomly adds menu items.

Description

CP Nav randomly adds menu items to a layout. I think at some points it still uses the navigation layout from the admin role. I made a screencast to show the problem.
https://chilli.d.pr/XeLEzO/hSK6IFMgl1

Steps to reproduce

  1. Make a new user with an editor role
  2. Login in the cp with this new user (Firefox)
  3. Login as admin in another browser, Chrome
  4. Try to add new menu items in the CP Nav plugin
  5. Go to your Firefox browser and refresh
  6. Go back to Chrome and refresh
  7. The order is wrong and menu items have been added.

Additional info

  • Plugin version: 2.0.6
  • Craft version: 3.0.7

Craft3 error

Description

The plugin looks like it installed properly but when I go into setting it see the following:
Database Exception – yii\db\Exception
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'staging.craft_cpnav_layout' doesn't exist
The SQL being executed was: SELECT *
FROM craft_cpnav_layout
Error Info: Array
(
[0] => 42S02
[1] => 1146
[2] => Table 'staging.craft_cpnav_layout' doesn't exist
)

Caused by: PDOException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'staging.craft_cpnav_layout' doesn't exist
in /pathToMyProject/craft/vendor/yiisoft/yii2/db/Command.php at line 1067

Steps to reproduce

  1. I used the Plugin Store to install.

Additional info

  • Plugin version: 2.0.2
  • Craft version: Craft Pro 3.0.0-RC3

Install via cli throws error

Description

The plugin throws an error if you install it through the cli.

$ ./craft install/plugin cp-nav
*** installing cp-nav
    > create table {{%cpnav_layout}} ... done (time: 0.018s)
    > create table {{%cpnav_navigation}} ... done (time: 0.023s)
    > add foreign key cpnav_navigation_layoutId_fk: {{%cpnav_navigation}} (layoutId) references {{%cpnav_layout}} (id) ... done (time: 0.023s)
*** failed to install cp-nav: Calling unknown method: craft\console\Request::getUrl()

Steps to reproduce

  1. composer require verbb/cp-nav
  2. ./craft install/plugin cp-nav

Additional info

  • Plugin version: 2.0.8
  • Craft version: 3.0.28

Translation / locale support.

It seems like the plugin breaks the locale translations of the labels for default menu items. For example, prior to installing the plugin, the Dashboard link in the French locale was translated as Tableau de bord. After installing the plugin it reverted to the translation for the English locale which is my primary locale.

My suggestion would be that this plugin follows Craft's default behavior and checks the site static translation files to see if there is a localized translation for the menu item label. In this way standard menu items would continue to be translated on a per locale basis as they have been, and it would also allow for adding locale translation for custom menu items added via the plugin.

I realize that I can override the menu item name in a layout for a user group by manually changing the menu item label, but this isn't ideal because it is possible to have members of a single user group that have different locale preferences. So choosing one locale for a user group and manually translating it isn't a very good option.

I realize this request probably entails a lot of work but I just wanted to mention it because I thought it would be a good addition for future versions. Other than that, this plugin is awesome. Thanks for the great resource.

Suggestion: Redirect to first available tab on login

Comment relating to Twitter conversation...

Almost perfect - I can disable the Dashboard tab (and the user can't re-enable it as it's globally hidden), but even if I hide the dashboard globally it's still the first tab that users see when they login (see screenshot). Is there any way to redirect users to the first enabled tab (Entries) on login?

image

I found a config setting that does this (postCpLoginRedirect) maybe there's a way to build this into the plugin so that the user gets redirected to the first available tab if the Dashboard is turned off?

Stopped working on RC17.1 to 3.0.1 update

I had a working setup with CP-NAV but it's not working anymore since updating to the 3.0.1 release of Craft. If I go to admin/cp-nav and press one of the lightswitches (turn a menu item on or off), I temporarily see the stored custom menu on the left, but it disappears again when clicking on a menu item / away from admin-cp-nav.

Missing subnav items for plugins with custom labels

Description

CpNavService::modifyCpNav() makes the assumption that the handle of a navigation item is the same as its url in the cpnav_navigation table. This is true most of the time, but some plugins, like sprout-lists, allow the user to set a custom label for navigation items, which is causing subnav items to be missed and possibly other unpredictable behavior. cp-nav probably shouldn't be using the display label to look things up, which is supposed to be presentational. The url is more stable.

Steps to reproduce

  1. Install sprout-lists
  2. Change display name of sprout-lists under its settings
  3. Confirm subnav items exist under Sprout Lists in the control panel
  4. Install cp-nav
  5. Subnav items are now missing under Sprout Lists

It does not happen when Sprout Lists is installed second because cp-nav picks up its default url and label.

Additional info

A fix might be to try to use the url first, not the label, to generate the handle and then fall back to the label instead of the other way around. Possible refactoring of CpNavService::regenerateNav() could be

foreach ($currentNav as $value) {
                if (isset($value['url'])) {
                  $handle = str_replace(UrlHelper::url() . '/', '', $value['url']);
                } else {
                  $handle = StringHelper::toKebabCase($value['label']);
                }
                if (!isset($generatedNav[$handle]) && !CpNav::$plugin->navigationService->getByHandle($layoutId, $handle)) {

                    if (isset($value['icon'])) {
                        $icon = $value['icon'];
                    } else {
                        $icon = null;
                    }

                    $model = $this->_prepareNavModel([
                        'layoutId' => $layoutId,
                        'handle'   => $handle,
                        'label'    => $value['label'],
                        'order'    => $order,
                        'icon'     => $icon,
                        'url'      => $handle,
                    ]);
  • Plugin version: 2.0.4
  • Craft version: 3.0.3

"Control Panel Layout" field type

Just wondering, what is the purpose of the Control Panel Layout field type?

On a similar note, I don't like that an actual field was automatically created for me. Is this necessary? It doesn't seem to be necessary... I deleted the field, and the plugin still works fine otherwise.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.