Welcome to the codeflair blog!

Here, you can find interesting bits and pieces we find in our work and about codeflair itself.


 

Limiting allowed cq:tags-path within namespaces

13.01.2015
Christoph Thommen

A common issue when working with CQ tags is the lack of possibility to limit the user entering only specific trees of tags within a namespace in a specific TagInputField.

Example

We have a tag structure like:

  • /etc/tags/search/keyword/…
  • /etc/tags/search/client/…
  • /etc/tags/search/…/…

Now we want the user to enter keywords (and only keywords) in the page property field “Keywords”.

The issue we’re no facing is, that in CQ only allowed namespaces can be limited, but not paths inside a namespace.

 

To solve this, the following listener attached to the TagInputField in the dialog.xml might help:

This listener is fired each time a tag is added to the TagInputField. The listener checks if the tag is located inside the desired path (in our case “/keyword”). If not, it will be removed again immediately.

 

This is a really easy way to restrict TagInputField to certain tag paths.

CQ5 / AEM: Simulating Publish on Author

29.11.2014
Christoph Thommen

For the first blog post, we have something small but quite handy:

Some components in CQ are administered in one place and displayed in multiple places.

This post shows how you can display a section of content without the authoring capabilities to improve the author experience.
At the same time, we omit any html decoration tags usually included on the author, this often makes it easier to make advanced html markup look nice on author.

To do this, we need two imports in our jsp file:

Then, before the section to be displayed like on publish, place the following code:

To revert back to regular author mode, add this piece of code:

done!