Skip to content

WFA Extensions

WFA Extensions provide ways to control page and modules life cycle at client side (admin ux).

Admin wide included inline setting html-admin-header.

Data models

Page model

If window.wfa_model_page_extension function is defined, it will be used to extend the _wfca/model/page data model.

The signature should match with:

javascript
window.wfa_model_page_extension = function (Base, $, _, i18n) {
    return Base.extend({
        ...
    });
};

The following example add, every time page is saved, one and only one fixed tag:

javascript
<script>
    window.wfa_model_page_extension = function (Base, $, _, i18n) {
        return Base.extend({
            save: function (xs) {
                $('#page_edit_simpleTags').val('single-tag').trigger('change');
                return Base.prototype.save.apply(this, arguments);
            },
        });
    };
</script>

General functionality

Video player

If window.wf_video_ext function is defined, it will be used to extend the video.js behaviour. The function has in consideration the video source like "local" defined in video data-source attribute to target desired type of content.

The function call should match with:

javascript
const k = ((window || {}).wf_video_ext || {})[source] || function (f, v) { f() };
k(fDefault, videos[i]);

The following example is defined in settings html-page-topb.txt:

javascript
<script>
    window.wf_video_ext = {
        local: (f, vp) => {
            // f - is the default video.js behaviour, it can be used if needed
            // vp - is the video player element that contains video thymbnail (figure) and video tags.
            console.log("Video Extension - Video source: local");
            var video = vp.querySelector("video");
            var figure = vp.querySelector("figure");
            ...
        },
        // Other cases can be added
        dailyMotion: (f, vp) => {...},
        ...
    };
</script>