Handling content class element names and other parameters

Because jRQL accesses all page elements via content class element names you need to feed your scripts and batch programs with these names.

Within all productive used plugins and batch programs I never use hard coded element names, because I wouldn’t have the chance to change these names easily.

In short, this is not a way of configuring all plugins with element names and other parameters. I use this hard coded approach only for on the fly programs I need to run usually once (directly running within Eclipse) but never productive.

I want to have all element names and other parameters within RedDot CMS. This store all elements names as close as possible to the content classes. And, in addition, I can even reuse a parameter on different plugins, simply by connecting to an existing parameter page.

To achieve this, I introduced 2 special content classes and a utility Java class to access these parameter values. Both are tightly connected.

For every plugin use an instance of content class rql_script, which has in the container parameters several instances of rql_script_parameter:

Above image shows one way to define parameters – using the headline of pages rql_script_parameter. Left beside the = is the parameter name, right the value. I maintain this pages only via SmartTree, so no SmartEdit red dots are available. Another way is to put the parameter name in the headline (without a =) and put the value into the ascii text element value, what overcome the length limit on headline (256 characters).

You can download the content classes for your own creation of such structure.

In last step you need to know how to access such parameters from your jRQL programs.  Use a code snippet like this to getting access to your parameters:

String logonGuid = “0B1FBC04A6D94A45A6C5E2AC8915B698”;
String sessionKey = “C26CF959E1434E31B7F9DA89829369B4”;
String projectGuid = “73671509FA5C43ED8FC4171AD0298AD2”;

CmsClient client = new CmsClient(logonGuid);
Project project = client.getProject(sessionKey, projectGuid);

ScriptParameters parms = project.getParameters(“267761”);
String imageFragmentTmpltName = parms.get(“imageFragmentTmpltName”);
String numberListTmpltElemName = parms.get(“numberListTmpltElemName”);
String numberOfColumnsTmpltElemName = parms.get(“numberOfColumnsTmpltElemName”);

The method project.getParameters() needs the page ID of your rql_script instance, in our case the page “createGallery parameters” has the page ID 267761.

The next 3 lines receive the parameter values for the 3 given content class element names, what makes it possible to change the element names in the content class and  – don’t forget – the parameter values quite easy.

This approach assume that your parameters are defined always within the scope of a project. If you follow this approach and you need a plugin in several projects you need to create the same parameter values within different projects and use the parameter’s page ID (e.g. 267761) as an input parameter of your plugin or batch program.

Post a comment or leave a trackback: Trackback URL.


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: