hide publish hide title, hide type

 document.addEventListener('DOMContentLoaded', function () {


    var currentUrl = window.location.href;


    if (currentUrl.includes("node/6/edit")) {
        var elements = document.querySelectorAll('.form-item--title-0-value');
        elements.forEach(function (element) {
            element.style.display = 'none';
        });

        elements = document.querySelectorAll('#edit-status-wrapper');
        elements.forEach(function (element) {
            element.style.display = 'none';
        });
    }

    var selectElement = document.getElementById('edit-type');
    if (selectElement) {
        var selectedValue = selectElement.value;
        console.log( 'selectedValue edit-type:'+selectedValue );
        if(selectedValue == 'homepage'){
            var selectElementEditAction = document.getElementById('edit-action');
            if (selectElementEditAction) {
                console.log( selectElementEditAction );
                // Iterate over all options within the select element
                for (var i = 0; i < selectElementEditAction.options.length; i++) {
                    // Check if the current option's value is 'node_unpublish_action'
                    if (selectElementEditAction.options[i].value === 'node_unpublish_action') {
                        // Remove the option from the select element
                        selectElementEditAction.remove(i);
                        // Once the option is removed, break out of the loop
                        break;
                    }
                }
            }
        }
    }
   
    for (var i = 0; i < selectElement.options.length; i++) {
        // Check if the current option's value is 'node_unpublish_action'
        if (selectElement.options[i].value === 'All' || selectElement.options[i].value === 'homepage' ) {
            // Remove the option from the select element
            selectElement.remove(i);
            // Once the option is removed, break out of the loop
        }
    }

});

留言

此網誌的熱門文章

fix drupal 11 install error

[Decoupled Preview drupal 11] iframe module