<p>Can you not do this with something like CPNav? </p>

<p><a href="https://github.com/verbb/cp-nav" rel="nofollow noreferrer">https://github.com/verbb/cp-nav</a></p>

CC BY-SA 3.0
2017-10-30T09:16:03.083Z
2017-10-30T09:16:03.083Z
Jason Mayo
<p>Yes, it's possible. It will require two steps:</p>

<ol>
<li>Create a setting in your plugin for <code>pluginNameOverride</code></li>
<li>Use that setting in place of the default name of your plugin when loading your plugin</li>
</ol>

<p>This does not change the name of the URL slug for your plugin in the admin URL and has different behavior in the UI in Craft 2 and Craft 3.</p>

<hr>

<h2>Craft 2</h2>

<p>1) Add a new setting following the instructions in the docs: <a href="https://docs.craftcms.com/v2/plugins/plugin-settings.html#settings-page" rel="nofollow noreferrer">https://docs.craftcms.com/v2/plugins/plugin-settings.html#settings-page</a></p>

<p>2) Once you have your setting working. You can do this in the <code>getName</code> method of your primary plugin file:</p>

<pre><code>public function getName()
{
    $pluginName = Craft::t('Your plugin name');
    $pluginNameOverride = $this-&gt;getSettings()-&gt;pluginNameOverride;

    return $pluginNameOverride ? $pluginNameOverride : $pluginName;
}
</code></pre>

<p><em>Note: While this changes the name in the nav, it also changes the name in several other places, such as the list of plugins on the plugin page. If a user changes it to something odd, it may not be obvious to you or someone else debugging that the website has your plugin installed.</em></p>

<h2>Craft 3</h2>

<p>1) Add a new setting following the instructions in the docs: 
<a href="https://docs.craftcms.com/v3/extend/plugin-settings.html" rel="nofollow noreferrer">https://docs.craftcms.com/v3/extend/plugin-settings.html</a></p>

<p>2) Override the parent <code>label</code> value in the <code>getCpNavItem</code> method</p>

<pre><code>public function getCpNavItem()
{
    $parent = parent::getCpNavItem();

    // Allow user to override plugin name in sidebar
    if ($this-&gt;getSettings()-&gt;pluginNameOverride)
    {
        $parent['label'] = $this-&gt;getSettings()-&gt;pluginNameOverride;
    }

    return array_merge($parent,[
        'subnav' =&gt; [
            'sectionName' =&gt; [
                'label' =&gt; Craft::t('your-plugin', 'Tab Name'),
                'url'   =&gt; 'your-plugin/section-name'
            ]
        ]
    ]);
}
</code></pre>

<p><em>Note: This just changes your plugin name in the sidebar URL. Your plugin will continue to use its original name in the settings area.</em></p>

CC BY-SA 4.0
2017-10-30T11:51:18.943Z
2019-04-22T17:54:17.720Z
2019-04-22T17:54:17.720Z
Ben Parizek
<p>I'm creating a plugin but want to simplify the title that appears in the CMS' left-hand main navigation for my client. I understand that by default it pulls from the <code>getName</code> method but I want to choose something different than what's set there. Is it possible to do this?</p>

<plugin-development>
Change plugin title in main side nav
# Change plugin title in main side nav

(Asked by: username_0 on 2017-10-30)

I'm creating a plugin but want to simplify the title that appears in the CMS' left-hand main navigation for my client. I understand that by default it pulls from the `getName` method but I want to choose something different than what's set there. Is it possible to do this?

**Tags:** plugin-development


---

## 2 answers

### Answer by username_2 on 2017-10-30. Score: 4 | Accepted answer

Yes, it's possible. It will require two steps:

Create a setting in your plugin for pluginNameOverride
Use that setting in place of the default name of your plugin when loading your plugin

This does not change the name of the URL slug for your plugin in the admin URL and has different behavior in the UI in Craft 2 and Craft 3.

Craft 2
1) Add a new setting following the instructions in the docs: https://docs.craftcms.com/v2/plugins/plugin-settings.html#settings-page
2) Once you have your setting working. You can do this in the getName method of your primary plugin file:
public function getName()
{
    $pluginName = Craft::t('Your plugin name');
    $pluginNameOverride = $this->getSettings()->pluginNameOverride;

    return $pluginNameOverride ? $pluginNameOverride : $pluginName;
}

Note: While this changes the name in the nav, it also changes the name in several other places, such as the list of plugins on the plugin page. If a user changes it to something odd, it may not be obvious to you or someone else debugging that the website has your plugin installed.
Craft 3
1) Add a new setting following the instructions in the docs: 
https://docs.craftcms.com/v3/extend/plugin-settings.html
2) Override the parent label value in the getCpNavItem method
public function getCpNavItem()
{
    $parent = parent::getCpNavItem();

    // Allow user to override plugin name in sidebar
    if ($this->getSettings()->pluginNameOverride)
    {
        $parent['label'] = $this->getSettings()->pluginNameOverride;
    }

    return array_merge($parent,[
        'subnav' => [
            'sectionName' => [
                'label' => Craft::t('your-plugin', 'Tab Name'),
                'url'   => 'your-plugin/section-name'
            ]
        ]
    ]);
}

Note: This just changes your plugin name in the sidebar URL. Your plugin will continue to use its original name in the settings area.


---

### Answer by username_1 on 2017-10-30. Score: 1

Can you not do this with something like CPNav?

<https://github.com/verbb/cp-nav>


---

