evolution-cms / evolution

Welcome to the new evolution of MODX Evolution!
GNU General Public License v3.0
260 stars 96 forks source link

Manager - How to add recent snippet name or document name to browser tab (title)? #2101

Closed q2apro closed 2 years ago

q2apro commented 2 years ago

I work with a lot of snippets and lose the overview often.

It would be extremely helpful to have the name of the snippet that is edited in the browser set as title of the browser tab.

How can I make this happen? THanks.

q2apro commented 2 years ago

Found a solution:

  1. Create a plugin

  2. Add this code:

$e = &$modx->Event;

if ($e->name == 'OnDocFormRender' || $e->name == 'OnSnipFormRender')
{
    $output = "
        <script>
            // snippet title as document title
            if ($('#name').length > 0)
            {
                parent.document.title = $('#name').val();
            }
            // document alias as document title
            else if ( $('.inputBox[name=alias]').length > 0)
            {
                parent.document.title = $('.inputBox[name=alias]').val();
            }
        </script>
    ";

    $e->output($output);
}