How to add recent snippet name or document name to browser tab (title) in Manager?

25 Views Asked by At

I work with a lot of snippets opened in several browser tabs - and lose the overview often.

It would be very helpful to have the name of the snippet (or document) that is edited in the browser set as title of the browser tab.

How can I make this happen?

I guess a plugin is needed for this (listening to the edit event)?


The main problem is that Evolution CMS (Modx Evolution) loads the editor in an iframe.

1

There are 1 best solutions below

0
Avatar On

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);
}