Automatic activation of new content class elements in pages

Imagine you have a content class with a lot of pages as instances of it. Now you need to add a new element to this content class and want to import the new values for each page of this content class programatically.

In this scenario you might experience the problem, that the RQL command getting the page elements did not deliver the new element from the old page.

The reason for this is, that the CMS didn’t add the new page element only by adding the new element to the content class. I call this behavior, that the element is not activated on the page.

CMS solve this issue the way that the new page element will get activated, if you use the element somewhere in your display project variant’s code and access the page in SmartEdit or page preview. This was a big dilemma for me, because of often had thausands of pages I never can access in SmartEdit manually.

The good news is, that jRQL has an automatic activation mechanism built into. The only thing you need to do is to use the element in the SmartEdit code. I usually add a HTML comment with the value of the new element to achieve this.

What happens whtin jRQL? If you try to get the new element from a page of this content class (without using them in SmartEdit before) jRQL

  1. catches the exception that the element could not be found.
  2. Than it gets the whole SmartEdit HTML code of the page, what is similar of accessing the page in SmartEdit mode page closed. With this the CMS activate the new element on the page.
  3. jRQL gets all elements of the page again (page action=load) and try to find the given element again.

Step 3 now can end with an exception that the element cannot be found what is a programming mistake or it goes well, if you mentioned the new element in a comment of the template of your SmartEdit code.

Because I had this need very often in my projects and it’s impossible to go through all pages in SmartEdit only to activate new elements I added this feature.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: