Cognos 中是否有用于导入样式表或 Javascript 的可编辑文件?

发布于 2024-10-20 10:28:47 字数 529 浏览 8 评论 0原文

我最近询问全局样式表在哪里用于编辑 Cognos 10 样式 (此处)。

经过与我们团队的一些讨论后,我们希望找到 Cognos 用于构建其报告查看器页面和仪表板小部件持有者的 CGI 或基本导入文件。

我们想要这样做的原因是这样我们可以将所有自定义样式和 javascript 包含在一个位置。当/如果我们升级 Cognos,我们可以确定我们的报告会出现一个故障点。这将解决我们必须重新编辑多个样式表(和 JavaScript)的问题。

我通常熟悉 ASP.NET 而不是 CGI-BIN。是否有类似于母版页的东西,可以为 Cognos 页面完成样式和基本导入?理想情况下,编辑此文件将使我们能够继续进行自定义。

这可以做到吗?或者我们只是疯了?我们了解有关升级的风险,但也接受这些风险(除非有人可以提供一个很好的例子来说明如何通过版本更改来复制此技术)。

I have recently asked where global stylesheets are for editing Cognos 10 styles (Here).

After some discussions with our team we would like to find the CGI or base imported file that Cognos uses to construct it's report viewer pages and dashboard widget holders.

The reason we want to do this is so that we can include all our custom style and javascript in one location. When/If we upgrade Cognos we can be sure of one point of failure with our reports. This would solve our problem of having to re-edit multiple stylesheets (and javascript).

I'm normally familiar with ASP.NET and not CGI-BIN. Is there something akin to a Master page where styles and basic imports are done for a Cognos page? Ideally editing this file would allow us to continue our customizations.

Can this be done? Or are we just insane? We understand the risks concerning upgrades, but are OK with the risks (unless someone can provide a good example of how this technique would not be replicated via version changes).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓝眼泪 2024-10-27 10:28:47

我认为像我这样具有更传统 Web 开发背景的 BI 专业人士对更改全局 CSS 文件并引入更多 JS 毫无疑虑,这是相当常见的。

我已经向您解释了如何在报告中运行 JS - 我很乐意将 jQuery 添加到我们的全局库中,但我还没有为它争取到足够的支持。不过我可以帮助解决 CSS 部分。

在 8.4.1 中,报表查看器引用了大量 CSS 文件。如果我是您,我会使用默认样式呈现示例报告,并使用 Firebug 或类似工具来跟踪正在调用的 CSS 文件。您会发现 server/cognos8/schemas/GlobalReportStyles.css 经常被引用,并得到 server/cognos8/skins/corporate/viewer/QSRVCommon.css 的帮助 -那里还有一些导入的其他文件。

我想你可以 grep -R '在 COGNOS 目录中查看该文件被调用的位置,然后直接编辑该文件,或者创建指向您自己的 JS 的链接。就我个人而言,我只是备份现有的样式表并修改已有的样式表。

我想你可以对 JS 做类似的事情 - 找到它在模板中被调用的位置(使用 grep),然后创建对你想要创建的文件的新引用。就我而言,如果我可以将 jQuery 加载到每个报告中,我会进行后空翻。

I think it's fairly common that BI professionals with more traditional web development backgrounds like me and you have no qualms with making changes to the global CSS files and bringing in more JS.

I've explained to you how I run JS in a report - I'd love to add jQuery to our global libraries, but I haven't drummed up enough support for it yet. I can help with the CSS portion though.

In 8.4.1, there's a ton of CSS files referenced by the report viewer. If I were you, I'd render a sample report with the default styling and use Firebug or similar to trace the CSS files being called. You'll find that server/cognos8/schemas/GlobalReportStyles.css is commonly referenced, with some help from server/cognos8/skins/corporate/viewer/QSRVCommon.css - there's also some other files in there that are imported.

I'd imagine you could grep -R '<link rel=\"stylesheet\" type=\"text/css\" href=\"../schemas/GlobalReportStyles.css\"> in the COGNOS directory to see where the file is being called, and either edit that file directly, or create a link to your own JS. Personally, I'd just backup the existing stylesheet and modify the one that is already there.

I'd imagine you could do something similar for the JS - find where it's being called in the template (using grep) and just create a new reference to the file you'd like to create. In my case, I'd do a backflip if I could get jQuery loaded into every report.

清风挽心 2024-10-27 10:28:47

才发现这已经一岁了。 :-( 抱歉,第一次来这里。如果有人仍然对该主题感兴趣,我会保留它。

这里是 有关自定义 Cognos 的文档在几个层面上:

我们使用了一种替代方法来修改系统文件,我们有一个共享组件“报告”,其中包含一个带有我们特定CSS覆盖的HTML对象,和/或一个指向自定义样式表的链接,然后我们将其添加到每个组件上。如果我们想要进行全局更改,只需更改组件报告或自定义样式表中的一项即可。

Just realized this is a year old. :-( Sorry, first time here. I'll leave it in case anyone is still interested in the topic.

Here is the documentation on customizing Cognos on several levels:

We used an alternative to modifying the system files. We have a shared component "report" containing an HTML object with our particular CSS overrides on it, and/or a link to a custom stylesheet. We then add this on each report with a "Layout Component Reference" from the toolbox. If we want a global change, just change the one item in the component report or custom stylesheet. This works very well for us.

笙痞 2024-10-27 10:28:47

我对这个问题之前的两个答案都投了赞成票。我承认我有点忘记了这个问题,直到有人对此进行了一些活动。

我们最终将上述技术结合起来。我能够按照建议找到全局样式表。我最终所做的就是复制该样式表中的所有样式,并创建一个后缀为 *_SystemSytles.css* 的新表。我创建了第二个工作表并添加了 *_Custom.css* 后缀。然后在原始工作表中我放置了两个导入,首先导入系统样式,然后导入自定义样式。

对于某些报告,我们有一个放置在其上的自定义对象,它引入了自己的样式(和 JavaScript)。这使用了与第二个问题类似的技术。

然而,要导入 JavaScript 以供整个 Cognos 站点中通用使用,我必须做的事情很困难。

在核心 webcontent 文件夹中,我创建了一个 js 文件夹,其中包含 jQuery 和我们的自定义 JavaScript 文件。然后,在一系列 JavaScript 文件中,我包含了类似于以下内容的代码:

/************************
JQUERY UTIL INCLUDE
************************/

function loadjscssfile(filename, filetype, id) {
    if (filetype == "js") { //if filename is a external JavaScript file
        var fileref = document.createElement('script')
        fileref.setAttribute("type", "text/javascript")
        fileref.setAttribute("src", filename)
        if (id)
            fileref.setAttribute("OurCompanyNameAsAnID", id)
    }
    else if (filetype == "css") { //if filename is an external CSS file
        var fileref = document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        fileref.setAttribute("href", filename)
    }
    if (typeof fileref != "undefined") {
        var headTag = document.head || document.getElementsByTagName('head')[0];

        headTag.appendChild(fileref);
    }
}

function _PortalLoadJS() {
    if (!window._PortalScriptsLoaded) {
        var pathParams = [];
        var path = location.href;
        (function () {
            var e,
            r = /([^/]+)[/]?/g,
            p = path;

            while (e = r.exec(p)) {
                pathParams.push(e[1]);
            }

        })();

        var baseURL = location.protocol + '//';

        for(var i = 1; i < pathParams.length; i++) {
            if(pathParams[i] == 'cgi-bin')
                break;

            baseURL += pathParams[i] + '/';
        }

        loadjscssfile(baseURL + "js/jquery-1.6.1.min.js", "js");
        loadjscssfile(baseURL + "js/Custom.js?pageType=COGNOS_CONNECTION", "js", "SumTotalUtil");
        window._PortalScriptsLoaded = true;
    }
}

if(!window.$CustomGlobal) {
    window.$CustomGlobal= function(func) {

        if (!window.$A) {

            if (!window.__CustomExecStack) {
                window.__CustomExecStack= new Array();
            }

            window.__CustomExecStack.push(func);
        }
        else
            $A._executeCustomItem(func);
    }
}

try {


    // Catch cases where $(document).ready() is called after the
    // browser event has already occurred.
    if (document.readyState === "complete") {
        // Handle it asynchronously to allow scripts the opportunity to delay ready
        setTimeout(_PortalLoadJS, 10);
    }

    // Mozilla, Opera and webkit nightlies currently support this event
    if (document.addEventListener) {
        // Use the handy event callback
        document.addEventListener("DOMContentLoaded", function() { _PortalLoadJS(); }, false);

        // A fallback to window.onload, that will always work
        window.addEventListener("load", _PortalLoadJS, false);

        // If IE event model is used
    } else if (document.attachEvent) {
        // ensure firing before onload,
        // maybe late but safe also for iframes
    document.attachEvent("onreadystatechange", function() { _PortalLoadJS(); });

        // A fallback to window.onload, that will always work
    window.attachEvent("onload", _PortalLoadJS);
    }
}
catch (ex) { }

$A 项是我在加载 Custom.js 文件时创建的项。

以下是我包含此代码的文件列表(位于 JavaScript 的不同末尾):

  • webcontent\icd\bux\js\bux\bux.core.js
  • webcontent\ps\portal\js\cc.js
  • webcontent \rv\CCognosViewer.js
  • webcontent\rv\GUtil.js
  • webcontent\rv\viewer.standalone.core.js

这些文件应覆盖 Cognos Connection、报表查看器和仪表板区域。如果发现更多,请告诉我,我可以更新此列表。

链接到 Custom.js 文件时,我在 Custom.js 文件选取的外部资源上放置了一个查询字符串:pageType=COGNOS_CONNECTION。这允许我为 Cognos Connection、报表查看器或仪表板执行特定的加载代码。

以下是 Custom.js 类中初始化 $A 对象的代码:

function _CustomUtilInit() {
    try {
        if (!window.$j) {
            window.setTimeout(_CustomUtilInit, 1);
            return;
        }

        var jScriptTags = $j('SCRIPT[' + Analytics.SCRIPT_ATTR_NAME + '= ' + Analytics.SCRIPT_ATTR_VALUE + ']');

        jScriptTags.each( function(i, scriptElem) {

            var tag = $j(scriptElem);

            if(tag.attr(Analytics.LOADED_SCRIPT_KEY))
                return;

            var scriptURL = new URI(tag.attr('src'));

            var analyticsPageType = scriptURL.getQueryStringValue(Analytics.PAGE_TYPE_QUERY_KEY, Analytics.PageType.REPORT_VIEWER);

            if(!window.$A) {
                window.$A = new Analytics();
            }

            window.$A.init(analyticsPageType);

            tag.attr(Analytics.LOADED_SCRIPT_KEY, 'true');
        });
    } catch (e) {
    }
}

_CustomUtilInit();

当然,这要求 jQuery 库包含在前面提到的每个 JavaScript 文件中的 Custom.js 文件之前。

URI 类是我在互联网上找到的,并根据我们的使用进行了调整。如果您对自定义 JavaScript 加载有任何疑问,请发表评论,我会尽力详细说明。

I up-voted both the previous answers to this question. I'll admit I kind of forgot about this question till someone put some activity on it.

We ended up doing a combination of the above techniques. I was able to find the global stylesheets as suggested. What I ended up doing was copying out all the styles that were in that stylesheet and created a new sheet suffixed with *_SystemSytles.css*. I created a second sheet and suffixed it with *_Custom.css*. Then in the original sheet I placed two imports, first importing the system styles and then the custom styles.

For certain reports we have a custom object that is dropped on that brings in its own styles (and JavaScript). This utilizes a similar technique to the second question.

However, what I had to do for import the JavaScript for general use within the entire Cognos site was difficult.

In the core webcontent folder I created a js folder that contained the jQuery and our custom JavaScript files. Then in a series of JavaScript files I included code similar to the following:

/************************
JQUERY UTIL INCLUDE
************************/

function loadjscssfile(filename, filetype, id) {
    if (filetype == "js") { //if filename is a external JavaScript file
        var fileref = document.createElement('script')
        fileref.setAttribute("type", "text/javascript")
        fileref.setAttribute("src", filename)
        if (id)
            fileref.setAttribute("OurCompanyNameAsAnID", id)
    }
    else if (filetype == "css") { //if filename is an external CSS file
        var fileref = document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        fileref.setAttribute("href", filename)
    }
    if (typeof fileref != "undefined") {
        var headTag = document.head || document.getElementsByTagName('head')[0];

        headTag.appendChild(fileref);
    }
}

function _PortalLoadJS() {
    if (!window._PortalScriptsLoaded) {
        var pathParams = [];
        var path = location.href;
        (function () {
            var e,
            r = /([^/]+)[/]?/g,
            p = path;

            while (e = r.exec(p)) {
                pathParams.push(e[1]);
            }

        })();

        var baseURL = location.protocol + '//';

        for(var i = 1; i < pathParams.length; i++) {
            if(pathParams[i] == 'cgi-bin')
                break;

            baseURL += pathParams[i] + '/';
        }

        loadjscssfile(baseURL + "js/jquery-1.6.1.min.js", "js");
        loadjscssfile(baseURL + "js/Custom.js?pageType=COGNOS_CONNECTION", "js", "SumTotalUtil");
        window._PortalScriptsLoaded = true;
    }
}

if(!window.$CustomGlobal) {
    window.$CustomGlobal= function(func) {

        if (!window.$A) {

            if (!window.__CustomExecStack) {
                window.__CustomExecStack= new Array();
            }

            window.__CustomExecStack.push(func);
        }
        else
            $A._executeCustomItem(func);
    }
}

try {


    // Catch cases where $(document).ready() is called after the
    // browser event has already occurred.
    if (document.readyState === "complete") {
        // Handle it asynchronously to allow scripts the opportunity to delay ready
        setTimeout(_PortalLoadJS, 10);
    }

    // Mozilla, Opera and webkit nightlies currently support this event
    if (document.addEventListener) {
        // Use the handy event callback
        document.addEventListener("DOMContentLoaded", function() { _PortalLoadJS(); }, false);

        // A fallback to window.onload, that will always work
        window.addEventListener("load", _PortalLoadJS, false);

        // If IE event model is used
    } else if (document.attachEvent) {
        // ensure firing before onload,
        // maybe late but safe also for iframes
    document.attachEvent("onreadystatechange", function() { _PortalLoadJS(); });

        // A fallback to window.onload, that will always work
    window.attachEvent("onload", _PortalLoadJS);
    }
}
catch (ex) { }

The $A item is an item that I create when the Custom.js file is loaded.

Here are the list of files that I've included this code (at the vary end of the JavaScript):

  • webcontent\icd\bux\js\bux\bux.core.js
  • webcontent\ps\portal\js\cc.js
  • webcontent\rv\CCognosViewer.js
  • webcontent\rv\GUtil.js
  • webcontent\rv\viewer.standalone.core.js

These files should cover the Cognos Connection, Report Viewer, and the Dashboards area. If any more are found please let me know and I can update this list.

When linking to the Custom.js file I put a query string on the external resource that the Custom.js file picks up: pageType=COGNOS_CONNECTION. This allows me to do specific load code for the Cognos Connection, Report Viewer, or the Dashboards.

Here is the code in the Custom.js class that inits the $A object:

function _CustomUtilInit() {
    try {
        if (!window.$j) {
            window.setTimeout(_CustomUtilInit, 1);
            return;
        }

        var jScriptTags = $j('SCRIPT[' + Analytics.SCRIPT_ATTR_NAME + '= ' + Analytics.SCRIPT_ATTR_VALUE + ']');

        jScriptTags.each( function(i, scriptElem) {

            var tag = $j(scriptElem);

            if(tag.attr(Analytics.LOADED_SCRIPT_KEY))
                return;

            var scriptURL = new URI(tag.attr('src'));

            var analyticsPageType = scriptURL.getQueryStringValue(Analytics.PAGE_TYPE_QUERY_KEY, Analytics.PageType.REPORT_VIEWER);

            if(!window.$A) {
                window.$A = new Analytics();
            }

            window.$A.init(analyticsPageType);

            tag.attr(Analytics.LOADED_SCRIPT_KEY, 'true');
        });
    } catch (e) {
    }
}

_CustomUtilInit();

Of course this expects that the jQuery libraries were included before the Custom.js files in each of the previously mentioned JavaScript files.

The URI class is something that I've found on the internet and tweaked for our use. If you have any questions regarding the custom JavaScript loading please leave a comment and I'll do my best to elaborate some more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文