Tuesday, 25 February 2014

Adobe AEM/CQ overwriting built-in plugins for richtext editor

Example given here -
to overwrite the built-in link configuration dialog box by adding a field to set a link title:
http://forums.adobe.com/thread/1230814

Very important to compare the code given in the example for changes.

Overview:
  1. Setup in the apps director to create a "widgets" folder with these values
    • jcr:primaryType  = cq:ClientLibraryFolder
    • sling:resourceType = widgets/clientlib
    • categories = cq.wcm.edit
  2. Create a js file that overrides the built-in js plugin, note:
    • Initialize the name of the plugin
    • Register the name to the built-in xtype
    • Uses CQ.form instead of CUI.
  3. Create a js.txt and include the name of js file within



Friday, 21 February 2014

Adobe AEM/CQ seach results


Configure indexing for search:
http://helpx.adobe.com/experience-manager/kb/SearchIndexingConfig.html

Overview:
  1. Create a mapping with index to latest articles
  2. Components can retrieve articles via the mapping
  3. When new articles come in, update the mapping of index at the background
  4. Once the new mapping is complete, replace the mapping

Tuesday, 11 February 2014

Adobe CQ/AEM Query Builder - empty property

So at work, I was faced with a scenario where I have to use the CQ query builder to retrieve a bunch of articles that when they do not have a date property it will be selected along with the ones with date property that does not expire.

A little pseudo-code to show what I mean:

if (!article.hasDate) {
  return true;
} else {
  if (article.date >= now()) {
    return true;
  }
  return false;
}

Here are some articles I found online before I came up with a solution:



Finally, here is what I have in CQ query builder:

path=[path/to/articles]
type=cq:Page
99_property=@jcr:content/cq:template
99_property.value=[apps/path/to/template]
10_group.p.or=true
10_group.1_property=@jcr:content/offTime
10_group.1_property.operation=not
10_group.2_daterange.property=@jcr:content/offTime
10_group.2_daterange.lowerBound=[current-date-or-hardcode-date-for-testing]
10_group.2_daterange.lowerOperation=>=

This is now returning articles that does NOT have the offTime property; also it returns articles that DO have the offTime date and are current.

Wednesday, 5 February 2014

Adobe CQ/AEM package install behaviour - filter.xml

Encountered a problem that whenever a package is deploy / installed, it will overwrite existing content and folder structure that was setup.

Using the filter.xml under META-INF/vault, we can configure it in a way that it keep existing content intact.

http://www.wemblog.com/2012/04/how-to-change-package-install-behavior.html

There are three Modes available:

  1. replace: Normal behavior. Existing content is replaced completly by the imported content, i.e. is overridden or deleted accordingly.
  2. merge: Existing content is not modified, i.e. only new content is added and none is deleted or modified
  3. update: Existing content is only updated but never deleted



Add it under META-INF/vault/filter.xml
<?xml version="1.0" encoding="UTF-8"?>

<workspaceFilter version="1.0">
    <filter root="/content" mode="update"/>
</workspaceFilter>


Advance package filtering include / exclude regular expression

http://aemfaq.blogspot.com.au/2013/04/cq5-package-filter-includeexclude.html

Example META-INF/vault/filter.xml
<?xml version="1.0" encoding="UTF-8"?>

<workspaceFilter version="1.0">
    <filter root="/content" mode="update">
        <include pattern="/content/foo/bar/*"/>
        </filter>
</workspaceFilter>