5 Replies Latest reply on Dec 3, 2012 3:47 PM by sara2012sara

    How to enforce that a page is tagged before activation


      Our business partners would like to require authors to tag a page before activating it.


      They would like the authors to be able to activate the pages on their own right away if the page has been tagged.  ( i.e.they do not want to require another person to check and approve content in a workflow.)


      If the author tries to activate a page that is not tagged, then ideally they would like a message and/or the tagging UI to appear to force them to tag before activating. 


      I have been looking at coding something in a workflow, but have not found a way to accomplish this so far.


      We do have some code in the template that shows the author a javascript popup warning when the page is loaded in author mode if the page is missing tags, but it would be more ideal to check and enforce at the time of page activation request rather than just warn them during page load.


      Does anyone have ideas on this?

      Thanks very much...

        • 1. Re: How to enforce that a page is tagged before activation
          Jörg Hoh Adobe Employee

          By default there is the AssetReferenceSearch dialog, which is used for checking if all referenced tags and assets are already replicated.


          You could hook into the same process and extend





          in a way, that besides the logic of the AssetReferenceSearch (the dialog is in  CQ.wcm.AssetReferenceSearchDialog) also some custom logic is executed, which calls server-side logic, if your required tags are there. If these tags are not there, the activation process is not executed.


          It's a matter of extending some clientlibs to inject your code.


          kind regards,


          1 person found this helpful
          • 2. Re: How to enforce that a page is tagged before activation
            sara2012sara Level 1

            Thanks Jörg,


            This looks promising, thanks for pointing me to these files.


            I have not worked on customizing these .js files before, so I will do some more research and experiments there.


            When searching on SiteAdmin.Actions.js that you mentioned, I saw this article on how to make the a dialog appear when activating pages:

            http://blogs.adobe.com/dmcmahon/2012/07/04/cq5-4-how-to-display-a-confirmation-dialog-when -activating-pages/


            The combination of your suggestion to add a call to some custom tag-check logic in these files, along with the information on the dialog display logic may be a good direction to go....




            • 3. Re: How to enforce that a page is tagged before activation
              Jörg Hoh Adobe Employee

              Hi Sara,


              I would not completely overlay the siteadmin.Actions.js ... that's a bit too intrusive and you might run into problems when a servicepack brings a new SiteAdmin.Actions.js with it. Instead just overlay the function you want to change. Use the clientlib approach and create a new JS file, attach it to the same clientlib as the SiteAdmin.Actions.js and redefine in your JS file the function you want to change.



              • 4. Re: How to enforce that a page is tagged before activation
                sara2012sara Level 1


                I was able to get something working after a lot of new learnings.


                I overrode the activatePage and scheduleForActivation functions SiteAdmin.Actions.js and was able to use the clientlib approach to avoid overlaying the whole file.

                The functions now check for the existence of tags before calling AssetReferenceSearchDialog.  If no tags are found, the user is shown a dialog and not allowed to continue.


                I added similar logic to the sidekick.js file.  It works fine if I overlay the entire file, but I have had a lot of trouble getting to the point where I can override just the single getPublishConfig function.  I will keep looking for a solution there, and may try to post a new question on that topic...


                Thanks again for the help.



                An example of the new code is shown for activatePage:


                // ***Override of activatePage:***


                CQ.wcm.SiteAdmin.activatePage = function() {

                    var admin = this;

                    var paths = [];

                    var selections = this.getSelectedPages();  


                    for (var i = 0; i < selections.length; i++) {




                    var pagesMissingTags = [];


                    if (CQ.wcm.SiteAdmin.noAsset()) {

                        // this logic is for pages, not assets

                        //     iterate through the selected paths, checking for pages without tags:

                        for (var i = 0; i < selections.length; i++) {

                            var myPath=selections[i].id;

                            var pagePath = myPath +  "/jcr:content.1.json";

                            var pageInfo = CQ.HTTP.eval(pagePath );

                            var myTags =  pageInfo["cq:tags"];              

                            // check if they are tagged, add to list

                            if (myTags==undefined) {




                        if (pagesMissingTags.length > 0) {

                            // if some are not tagged, show dialog, stop 

                            var tagWarningDialogTitle = CQ.I18n.getMessage("Missing Tag Alert");

                            var tagWarningMessage = CQ.I18n.getMessage("WAIT! This page wasn't activated.");

                            tagWarningMessage += "<br/>";

                            if (pagesMissingTags.length > 1) {

                                tagWarningMessage += CQ.I18n.getMessage("The following pages are missing tags:");

                            } else {

                                tagWarningMessage += CQ.I18n.getMessage("The following page is missing tags:");                          


                            tagWarningMessage += "<br/><br/>";

                            var max = 5;

                            for (var i=0; i<pagesMissingTags.length; i++) {                 

                                if (i == max) {

                                    tagWarningMessage += CQ.I18n.getMessage("(and {0} more...)", [selections.length-i] ) + "<br/>";



                                var page = CQ.shared.XSS.getXSSRecordPropertyValue(pagesMissingTags[i], "title");

                                if (!page) {

                                    page = pagesMissingTags[i].get("label");


                                tagWarningMessage += "    " +  page + "<br/>";



                            tagWarningMessage += "<br/>";

                            tagWarningMessage += CQ.I18n.getMessage("In order for this content you created to be findable, you need to tag the page. Otherwise, no one will find it." );

                            tagWarningMessage += "<br/><br/>";

                            tagWarningMessage += CQ.I18n.getMessage("Right click on the page name and select 'Properties...' to tag the page now. ") ;










                        } else {

                            // all selected files have tags, so go ahead with

                            // standard activation logic (reference check)

                            var data = {

                                    id: CQ.Util.createId("cq-asset-reference-search-dialog"),

                                    path: paths,

                                    callback: function(p) {


                                        CQ.wcm.SiteAdmin.internalActivatePage.call(admin, p);



                            new CQ.wcm.AssetReferenceSearchDialog(data);

                        }  // end tag warning if/else




                    } else {  // item to activate is an asset, not a content page

                        // activate only the selected items


                        CQ.wcm.SiteAdmin.internalActivatePage.call(admin, paths);



                • 5. Re: How to enforce that a page is tagged before activation
                  sara2012sara Level 1

                  Note: this was actually done in CQ 5.4, so the modified code is from 5.4.