Hiding Cognos Connection Elements

Hiding Cognos Connection Elements

By default Cognos offers a ride range of UI options. Based on the group or role you can programmatically decide who can see which UI Elements. A simple modification of the system.xml file is all that is needed to take care of this.

The Admin and Security guide, which can be found in the \webcontents\documentation\en\ug_cra.pdf, has an excellent article on how to accomplish this. You can also find the article online here.

The full list of elements that you can hide can also be found in the guide, or online here.

While those links are for 8.4, they are essentially identical for 8.4.1 and 10.1.

But what happens when you have a requirement to remove elements that don’t appear in the list? This is possible by modifying one of the template files that controls the structure of the portal. These files are saved as XSL files, and are easily modified using any text editor. I strongly recommend using a text editor with XML support, such as Notepad++.

Before I continue, it’s worth mentioning the following. Changing these files may be risky. A misplaced semicolon will prevent Cognos from loading, and IBM has a tendancy not to support installations that have modified the Cognos internals. These changes will also be overridden by any patches or upgrades.

Always make a backup of any files you modify. When trouble does occur and you need IBM’s help, simply switch the active files with the backup, and IBM will be none the wiser (and if the problem is fixed, you know where to look).
You should also maintain a change log of everything you do. Upgrades will replace the template files, and there may be differences between the versions. Instead of simply overwriting the upgraded version with your modified version, you should make all the changes again manually. Fortunately (unfortunately?) patches and version upgrades tend to be rare occurrences.

A brief explanation of the files to modify:

There are two primary XSL files which control the portal.
1. \templates\ps\logicsheets\presentation\controls\presentation.xsl
2. \templates\ps\logicsheets\presentation\main\presentation.xsl

The \controls\presentation.xsl renders, among other things, the HTML behind tabs, and the rows and columns in the Public Folders/My Folders table.

The \main\presentation.xsl renders the links to the correct style sheets, the page headers, and the individual links in the Public Folders/My Folders table.

Between the two, they control the HTML between most of the objects you see on the page.

The system.xml file that contains the UI black list can be found in \templates\ps\portal\system.xml

And now the problem. The client has decided that no user, except administrators and report authors, should be able to see the Properties or More… links for any reports or folders.

First, hiding the properties.

In the \main\presentation.xsl do a search for action_properties.gif. There should be four instances of that string. Each of these instances controls the properties for a different type of object. Series 7 object, CRN object, Job and… well, I’m not entirely sure what the fourth one is for, but I’m sure it’s very important. 5 points to whoever enlightens me.

In each of these four cases the action_properties.gif is part of a xsl:call-template reference.

This statement is calling the renderActions template with values for the onclick, icon and tooltip parameters.

In order to prevent this segment from being rendered we need to add it to the “Elements you can hide” list. The code that controls items on the list is as follows:

<out:if test="not(contains($ui_black_list, 'NAME'))">			

This will check the system.xml for an appearance of NAME in the ui_hide list. Should it appear, it will not render anything inside the code block except for users or groups listed in the show parameter. Knowing this, all that is needed to hide the properties is to add the black list code to all four appearances of the renderAction call.

		<out:if test="not(contains($ui_black_list, ' PROPERTIES '))">			
			<xsl:call-template name="renderAction">
				<xsl:with-param name="onclick">actions('{xtsext:javascriptencode(string($obj-name))}', '{$obj-class}', '{xtsext:javascriptencode(string($obj-path))}','properties_general.xts');</xsl:with-param>
				<xsl:with-param name="icon" select="'action_properties.gif'"/>
				<xsl:with-param name="tooltip" select="'IDS_PROPERTIES'"/>

In this case, I set the black list name to PROPERTIES. Now, in the system.xml simply add the following to the ui_hide param:

	<PROPERTIES show ="Administrators RSUsers"/>

When you restart, only administrators and authors will be able to see the properties for any object.

Now for the More…

The technique to hide the “More…” link is almost identical.

Simply find all occurences of IDS_ACT_MORE in the same file. In my modified file all occurences appear between lines 4640 and 4722. Thanks to Notepad++’s XML support, I can see that all of these are held inside a single group.

Instead of black listing each individual appearance of the More… link, let’s try black listing the entire group.

Now to add MORE to the system.xml black list

As before, only administrators and authors will be able to see the More… link.

The following shows how folders look to normal users:

And this is what reports look like:

It’s very important to do extensive tests to ensure this meets the client needs. You could probably also reverse the black list by getting rid of the “not()” from the code. Remember that the idea behind this article is not to simply show how to hide specific elements from the Cognos Connection. It’s to show how easily it is to shape Cognos to meet your needs. The XSL sheets are there to be modified.

Adding a Favicon

Favicons are the little images you have to the left of the URL in the URL bar. If you’re reading this through WordPress you should see a white “W” inside a blue circle. That is the WordPress Favicon.

The absolutely easiest way to add a Favicon is to add the image to the root folder of the web server. If you’re using IIS the default would be “C:\inetpub\wwwroot\”. Add the Favicon, flush the cache and reload Cognos. You should now see the Favicon.

This works great, but what happens if you have more than one site, or if you want different Favicons for different skins? You’ll need to modify the XSL.

While Cognos can (and probably should) be used with Firefox, a majority of users still use IE. So the favicon must be in the Microsoft Icon filetype (.ico).

To begin, decide which skin has what favicon and place them under ..\portal\images\ for each skin.

Next backup and open ..\templates\ps\logicsheets\presentation\main\presentation.xls

Search for “mt:stylesheet”. It should be on line 68. I’ll be entirely honest, I don’t know what this choose expression is testing. Either way, add the following line after the last stylesheet link in the “otherwise group”

<link rel="shortcut icon" href="{'{$skin_images}'}favicon.ico"/>

Restart Cognos and check if it works.

I’ve added the IBM favicon to the business skin and added the portal to my favorites:

Now I’ve added the Google favicon to the classic skin, and switched to it:

The favicons in the tab and the URL bar are immediately updated. However the favicons in the favorites will stay with the previous icon. Easy enough to fix – delete and re-add the favorite.

A few postscripts:
It’s worth noting that while this was testing on Cognos 10, I have no reason to believe it would not work on Cognos 8.
This method also relies on modifying Cognos internals. This will need to be redone every time you upgrade.
Also, make sure you make a backup of any file you modify.

Redirecting on logoff

When a user logs off from Cognos he gets to a “You are logged off” note with the option to log back in. Sometimes it is preferable to have the log off screen automatically redirect the user.

The file that controls the log off screen is found at ../templates/ps/portal/logoff.xts.

I highly recommend using an XML editor such as Notepad++ for making modifications to these files.

In this file search for the string <!– Standard meta tags –> (it should be on or around row 105). Paste <meta HTTP-EQUIV=”refresh” content=”2;url=http://www.google.com/”/> directly below that. Save and close.

It should look like:

<!– Standard meta tags –>
<meta HTTP-EQUIV=”refresh” content=”2;url=http://www.google.com/”/>

Before you can restart Cognos you will need to remove the portal.jar from ../webapps/p2pd/WEB-INF/lib/. The easiest way is to simply rename it to portal.jar.bak. This file contains many of the XTS files. Cognos will default to using the files in that JAR before the ones in the templates folder.

With the portal.jar file removed, restart Cognos. Log in, then log back out. If all goes well you should be redirected to google in 2 seconds.