C
C
Cheizer2020-02-05 18:38:20
css
Cheizer, 2020-02-05 18:38:20

How to generate ALIAS from MENUTITLE instead of PAGETITLE in MODX REVO?

Friends, please tell me if there is a solution, a setting in MODX REVO, so that alias would be created from the menutitle, and if the field is empty, then from the pagetitle. How to do it? The fact is that pagetitles are always huge, they are written for SEO, and the content is so complex, when translit works, it turns out to be a slightly different name that is simple in meaning that I would like, but in the menutitle I always write a short and simple name for the menu. I would like to take the title for the aliasa from it, and if it is empty, then, as usual, from the pagetitle. Any solutions?

I have a plugin for the OnDocFormSave event and it works.

if ($modx->event->name == 'OnDocFormSave') {
    if (!empty($resource->get('menutitle'))) {
        $resource->set('alias',$resource->get('menutitle'));
    }
    else {
        $resource->set('alias',$resource->get('pagetitle'));
    }
    $resource->save();
}


But the trouble is that with this plugin, ALIAS cannot be entered by hand, if you check for an empty alias, and if it is empty, do everything described above, if it is not empty, then do nothing.

if ($modx->event->name == 'OnDocFormSave') {
    if (empty($resource->get('alias'))) {
        if (!empty($resource->get('menutitle'))) {
            $resource->set('alias',$resource->get('menutitle'));
        }
        else {
            $resource->set('alias',$resource->get('pagetitle'));
        }
        $resource->save();
    }
}


But with this check for an empty ALIAS, the plugin stops working, for ALIAS, just PAGETITLE is taken as usual.
It looks like you can't get an ALIAS and do a check on it, it's always populated by the pagetitle system, is that right?
And how can I solve my problem?
How to do this, if the ALIAS field is empty, take the MENUTITLE field for ALIAS, and if MENUTITLE is empty, then take the PAGETITLE as usual. How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2019-05-21
@olya_097

Div to which the background is a picture, Create a pseudo to which you create a black background with transparency, large in the size you need Position it on the left edge, transform the rotation by the required number of degrees On the parent overflow hidden overflow: hidden;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question