Saturday 9 June 2012

Customize column control


      OOTB provides components related to the  column controls, but If we directly drag and drop the components on to the page, we can't find such number of columns in the column control. Because we need to add styles to define different columns:
Here you go..

Customize column control:
------------------------
Add the following styles in css:

/* layout 0 : 50% 50%  i.e., two columns wiht 50% , 50%*/

div.cq-colctrl-lt0 { }
div.cq-colctrl-lt0-c0 { width: 340px; margin-right:10px}
div.cq-colctrl-lt0-c1 { width: 340px; margin-left: 10px}

/* layout 1 : 33% 33% 33%  Three columns */
div.cq-colctrl-lt1 { }
div.cq-colctrl-lt1-c0 { width: 220px; margin-right: 10px;}
div.cq-colctrl-lt1-c1 { width: 220px; margin-left: 10px; margin-right: 10px;}
div.cq-colctrl-lt1-c2 { width: 220px; margin-left: 10px; }

Add follwoing colctrl design mode:
-----------------------------------
2;cq-colctrl-lt0      2 Columns (50%, 50%)
3;cq-colctrl-lt1      3 Columns (33%, 33%, 33%)

so that we can get options for two & three columns.

Saturday 5 May 2012

Customize Sidekick


      Have a requirement where we need to add 'Preview Publish Page' button/item under the Page tab in the Sidekick. On click of the button/item it would popup a new window with the target url of that page in Publishing instance.
In short I want a capability of the adding a feature in side kick which will give me a publishing instance preview of the page.   
My approach:  We can find sidesick.js (libs/cq/ui/widgetes/source/widgets/wcm/SideKick.js) where all the properties  like Copy Page,
Move Page, Activate Page and so on..are configured..
So I'm going to add one more entry called 'preview Publish page' in the Same sidekick.jse and I can able to see 'prview publish page' button in the sidekick.Now, I will configure that entry to open a new window which redirects to the publish page url.

Customize sidekick:
----------------------------------------------------------------------------------------------------
Here I’ve customized the SideKick.js such a way that it adds one more button called ‘Preview Publish Page’ under the Page tab in the sidekick. When we click on the button it opens a new window and opens the current page in preview mode.

Customization starts at Line no: 100 to 107 in SideKick.js
/** -------------- Custom ------------------**/
    /**
     * @cfg {String} previewPublishText
     * The text for the Preview Publish button (defaults to "Preview Publish Page").
     */
    previewPublishText:null,
      
    /** ----------------------------------------**/

Customization starts at Line no: 558 & Ends at 607 in SideKick.js
/** ------------------------------------------------------------------------------------------------------------------------------**/
    /**
     * Returns the config for the default Create Sub Page button.
     * @private
     * @return {Object} The config for the default Create Sub Page button
     */
    getPreviewPublishPageConfig: function() {
        var allowed = CQ.User.getCurrentUser().hasPermissionOn("wcm/core/privileges/modifyhierarchy", this.getPath()) &&
                CQ.User.getCurrentUser().hasPermissionOn("create", this.getPath());
        return {
            "text": this.previewPublishText,
            "disabled": !allowed,
            "handler": function() {
           
            if (!CQ.WCM.isPreviewMode()) {
                this.wcmMode = CQ.WCM.setMode(CQ.WCM.MODE_PREVIEW);
                if (!this.previewReload) {
                    CQ.WCM.getContentWindow().CQ.WCM.hide();
                } else {
                    CQ.Util.reload(CQ.WCM.getContentWindow());
                }
                this.collapse();
            } else {
                // make sure the button stays pressed
                this.previewButton.toggle(true);
            }
            var myRef = window.open(''+self.location,'mywin',
            'left=20,top=20,width=1000,height=700,toolbar=1,resizable=0', CQ.WCM.setMode(CQ.WCM.MODE_PREVIEW));
           
            /**  
             * This opens the specified url in new the tab
           
            window.open('http://www.techaspect.com/');  // --> this opens a new tab on my browser
            Ext.Ajax.request({
                url: 'PHP function call',
                success: function(response) {
                    window.open('http://www.techaspect.com/');  // --> this opens a new window, not tab
                }
            });
           
            */
            },
            "context": [
                CQ.wcm.Sidekick.PAGE
            ]
        };
    },

   
    /** --------------------------------------------------------------------------------------------------------------------------------**/
Added Line no: 3264

  "previewPublishText": CQ.I18n.getMessage("Preview Publish Page"),

Customization starts at Line no: 3680 - 3687
/** --------------------------------------------------------------***/
/**
 * The value for {@link #actions} to create a PreviewPublish page button.
 * @static
 * @final
 * @type String
 */
CQ.wcm.Sidekick.PREVIEWPUBLISH = "PREVIEWPUBLISH";
------------------------------------------------------------------
Added Line no: 3790
CQ.wcm.Sidekick.PREVIEWPUBLISH,

After adding the above lines of code in SideKick.js, we can see a customized button in sidekick as shown in the above figure.

 -------------------------------------------------------------------------------------------
=======================================================================

Tuesday 7 February 2012

Installing FileVault (VLT)

Problem: I've create a Bundle and wrote a java bean(Example.java). When I tried to Generate Getter and Setter methods I got error as follows:

Error Message: The resource is not on the build path of a java project





Solution:  Installing FileValut (VLT)

FileVault (VLT) is a tool developed by Day that maps the content of a CRX instance to your file system. The VLT tool has similar functionalities to those of an SVN client, providing normal check in, check out and management operations, as well as configuration options for flexible representation of the project content.

To install VLT, follow the steps:

  1. In your file system, go to <cq-installation-dir>/crx-quickstart/opt/filevault. The build is available in both tgz and zip formats.
  2. Extract the archive.
  3. Add <cq-installation-dir>/crx-quickstart/opt/filevault/vault-cli-<version>/bin to your environment PATH so that the command files vlt or vlt.bat are accessed as appropriate. For example, <cq-installation-dir>/crx-quickstart/opt/filevault/vault-cli-1.1.2/bin
  4. Open a command line shell and execute vlt --help. Make sure it displays the following help screen:

Wednesday 11 January 2012

Get Node Properties

<%@page import="javax.jcr.Session,javax.jcr.Node,org.apache.sling.jcr.resource.JcrResourceUtil,
com.day.cq.tagging.Tag,
com.day.cq.tagging.TagManager,com.day.cq.tagging.JcrTagManagerFactory"
%>



<%
     //Node node;

    Session session = slingRequest.getResourceResolver().adaptTo(Session.class);
    TagManager tagManager =   sling.getService(JcrTagManagerFactory.class).getTagManager(session);
    Tag tag = tagManager.resolve("/apps/webexample_siva/components/content/contact"); 

    //specify the path which you want to get
    Node node = tag.adaptTo(Node.class);
    String name= node.getName();
     
%>

//Iterate node properties and displays node property name and value

<%
     for(PropertyIterator propeIterator = node.getProperties() ; propeIterator.hasNext();)
     {
         Property prop= propeIterator.nextProperty();
         if(!prop.getDefinition().isMultiple())
         {
             
             %>
             
             <%=prop.getName() %> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=prop.getString() %> <br />
             <%
             
         }
         
     }
%>


Tuesday 10 January 2012

SCHEDULED PUBLISH

Method 1:

 Select the page that you want to publish in future.. 
    1. Right click on the page.
           --> Expand On/Off Time under the Blog Tab
           --> Set On time at which the page to be activated
       --> click 'Ok' 
    2. Active page

Method 2:

  Select Activate from the menu
  -- select Activelater  and set date & time

Result: The Scheduled page will be stored in the Publishing server but it will published on Scheduled time only.

On/Off Time Behavior:

On Time:
The date and time at which the published page will be activated. When published this page will be kept dormant until the specified time. Leave these fields empty for pages you want to publish immediately (the normal scenario).

Off Time:
The time at which the published page will be deactivated. Again leave these fields empty for pages you want to publish immediately.

Ref: http://dev.day.com/docs/en/cq/current/getting_started/first_steps_for_authors.html