Corporate Publisher Scripting – Example

This post is now actually looking a step further and is applying the basic knowledge of Corporate Publisher scripting into a real example; to create a HTML publication with a tabbed output.

If you haven’t seen the previous posts please read them first as you will miss valuable information that helps you to understand this post.

These are the previous posted articles.

Other posts of the serie

  1. Create a HTML Publication with tabs -
  2. Scripting in Corporate Publisher - Basic Knowledge -
  3. Corporate Publisher Scripting - Example (This post) -
  4. Corporate Publisher and Google Technology -
  5. Corporate Publisher Scripting - The Conclusion -

At the end of this post you can download the Corporate Modeler model, the Publication Set and the full output that was used in this example.

Adding Scripts in Corporate Publisher

You need to open Corporate Publisher Editor and navigate to the General Tab, here you can find the following settings.

Corporate Publisher - Global HTML Settings

In Corporate Publisher Editor in the General Tab you can find the Global HTML Setting. Tags specified here are placed immediately after the tag in each outputted HTML document.
Corporate Publisher Editor - Global HTML

Corporate Publisher Editor - Global HTML

Corporate Publisher Script for Head Section

Corporate Publisher Script for Head Section

In the left image you can see the usage of CP Scripting in Corporate Publisher Editor and you can see each script starts with <–#CPSTART# and ends with #CPEND–>. The first scripts are just references to different CSS (Cascade Style Sheets) as we want to have different colour coding for different POLDAT object types. In the last script you can find a link to an external file called “tabs_head.txt”, that is included in the script. With this technique you can embed external written code.

The example of the “tabs_head.txt” can be seen on the rigtht hand side image. It starts again with some CSS references, but more important here the first reference to our Ajax tabs, called “tabcontent.js” and “tab-to-tab-links.js”. You can find the full source code and description at Please Login or Register to see the link..

Corporate Publisher - HTML Header Settings

In Corporate Publisher Editor in the General Tab you can find the HTML Header Setting. Tags specified here are placed near the top of the body element of each outputted HTML document.
Corporate Publisher Editor - HTML Header

Corporate Publisher Editor - HTML Header

Corporate Publisher Script for Diagram Section

Corporate Publisher Script for Diagram Section

The left image has the “leftbar.txt” script that allows you to add a navigation bar on the left hand side. In the same way you could do a topbar with some head navigation items. In the middle of the screen you can find the CP Script for the “tabs_diagram.txt”, this one is actually the next steps to get a tabbed HTML output with Corporate Publisher.

You can see the full script in the right image, where we define the number and naming for our tabs. Once we have defined this we start with our first tab with the diagram picture. The diagram image will be inserted afterwards by Corporate Publisher.

Corporate Publisher - HTML Footer Settings

In Corporate Publisher Editor in the General Tab you can find the HTML Footer Setting. Tags specified here are placed near the end of the body element in each outputted HTML document.
Corporate Publisher Editor - HTML Footer

Corporate Publisher Editor - HTML Footer

Corporate Publisher Script for HTML Footer Section

Corporate Publisher Script for HTML Footer Section

In the left image you can see the HTML Footer section of Corporate Publisher, where you can see two different footer scripts, one for the diagrams and one for all object pages.
You can see the diagram footer script in the right image called “tabs_mainfooter.txt”, on top you can see the closing tag for the diagram section followed by new open tag for the next tab the “Version Control” tab. In this tab you can also see how you can use the Corporate Modeler properties within your scripts, e.g. #CP_OBJECTPROPERTY_whocreated#. If you are not sure about the script names please open Model Explorer in the Design View.

The Results of our Scripting Exercise

You can find the published output from our exercise here (Please Login or Register to see the link.) alternative you can view the extended POLDAT example (Please Login or Register to see the link.), alternatively you can also download the full source code, but you will need Corporate Modeler 2009.1 or later to use this example material.

The following screen shots will give you an overview of the achieved results.

Corporate Publisher - Published Output

The published output was optimized for Internet Explorer. The screen shots focusing mainly on the tab scripting and not on other functionality e.g. Feedback Form.
Corporate Publisher - Diagram Tab

Corporate Publisher - Diagram Tab

Corporate Publisher - Diagram Tab

Corporate Publisher - Diagram Tab

Corporate Publisher - Description Tab

Corporate Publisher - Description Tab

Corporate Publisher - Version Control Tab

Corporate Publisher - Version Control Tab

Corporate Publisher - Feedback Tab

Corporate Publisher - Feedback Tab

I hope all my example will help you to understand the Corporate Publisher Scripting better and would appreciate any feedback. Please download all relevant document here Please Login or Register to see the link..

Other posts of the serie

  1. Create a HTML Publication with tabs -
  2. Scripting in Corporate Publisher - Basic Knowledge -
  3. Corporate Publisher Scripting - Example (This post) -
  4. Corporate Publisher and Google Technology -
  5. Corporate Publisher Scripting - The Conclusion -

Comments

4 Responses to “Corporate Publisher Scripting – Example”

  1. prachi says:

    Hi Helmut,

    When using #CP_OBJECT_PROPERTY_# , how do we know the property name? Similarly how to find the name of the association?

    Thanks

    • Schindlwick says:

      The correct expression is #CP_OBJECTPROPERTY_#. You just need to add the script name (you get it from Model Explorer / Design View) of the property at the end of the expression #CP_OBJECTPROPERTY_#, e.g. if you want to publish the description with of an object this would be #CP_OBJECTPROPERTY_description#.
      http://schindlwick.com/toolbox/wp-admin/#comments-form

      • prachi says:

        Thanks Helmut,
        That helps. However this is limited to the property of the object. How do we figure out the name of “association” & “appears on” ?

        • Schindlwick says:

          The CP Scripting functionality of Corporate Publisher is not only limited to its properties, as you can also use the following script to visualize the associations of objects. #CP_OBJECTPROPERTY_crossreferences#

Leave a Reply