4

I'm wondering if I can have another name for my Plugin CP navigation item?

Let's say my plugin is called "Company name Social Media" but I want the navigation item to just say "Social Media". Might be a bad example but I think you understand what I mean. Let's say I'll release a commercial Craft plugin w/ my company name in it, but I want the customer to be able to add the plugin for a client without my name visible (more then on the plugins page).

Also is there any way to add dropdown-like sub-navigation items to the CP navigation for a plugin?

2 Answers 2

5

I don't know if it's possible to change the name of the CP section, but it has become a common practice to allow each user to change the plugin-name on its setting page:

main plugin file:

function getName() { return $this->getSettings()->name; } protected function defineSettings() { return array( 'name' => array(AttributeType::String, 'default' => 'SuperPluginName') ); } 

settings template:

{% import '_includes/forms' as forms %} {{ forms.textField({ first: true, label: "Plugin Name"|t, instructions: "How the plugin should be named in the CP"|t, id: 'name', name: 'name', value: settings.name, required: true }) }} 
2
  • Any tips or info about adding dropdown items to the navigation item? Commented Jul 3, 2014 at 6:38
  • If you mean a dropdown like the one from the settings-link, that is only possible if you add it with javascript. Commented Jul 3, 2014 at 12:12
2

I use Victor In's "getName" function with a minor addition of a check of the type of value returned. I do this because without the value check, I get an error when I try to uninstall a plugin without confirming the value is a string.

Here's my version of the function:

function getName() { $name = $this->getSettings()->name; if (is_string($name) ){ return $name; } else { return Craft::t( 'My Default Plugin Name Here' ); } } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.