cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript and CSS info in WPC

Former Member
0 Kudos

Hi all,

Is it possible to keep CSS (Stylesheet) and Javascript information from older html web pages and bring them into Web Page Composer? We have some older intranet web pages which we now want to display in the portal without ofcourse using URL iViews; so the content remains local to KM and the relevant roles can be assigned to different authors and editors of the website so it can be modified through the portal and WPC?

Any tips, hints and helpful suggestions are welcome.

Regards,

Tony.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Tony.

Yes, it's possible. Read [Wiki WPC FAQ|https://wiki.sdn.sap.com/wiki/display/KMC/WebPageComposer-FrequentlyAskedQuestions+%28FAQ%29#WebPageComposer-FrequentlyAskedQuestions%28FAQ%29-WhataboutusingstandardHTMLpagesinWPC%3F].

KM supports relative links in HTML documents so it may be necessary include any dependent files in the same folder as the HTML document.

In case of a web page and its dependent files are stored in different folders you need editing the source html code:

1. use Portal Drive and any text editor (I prefer Notepad++. It has the feature "Search and Replace in files") to open the html source file.

2. search for links to dependent files and add the following pattern: /irj/go/km/docs//<path to an dependent file>/ before a filename, for example:

You have a web page with css file. The page is stored in documents repository under the folder with ID old_pages. The css is resides in css folder.

So the existing code

 <LINK REL=STYLESHEET TYPE="text/css" HREF="css/style.css">

should be replaced with the

<LINK REL=STYLESHEET TYPE="text/css" href="https://answers.sap.com/irj/go/km/docs//documents/old_pages/css/style.css">

Best regards,

Aliaksandr

Former Member
0 Kudos

Hello,

Im trying to migrate a static HTML page from a legacy website into WPC. Ive imported the HTML in "Web Pages" directory of my site under "Web Content". It works fine when I preview the html page as it is without placing it in the Web Page "Container".

It is important to mention that there are some Java Script and CSS associated with this html page.

The problem arises when I place this HTML in a Web Page "container", by dragging and dropping this html page into one of the containers of my Web Page. When I do this (place the html in the container), it looses all its styling (CSS) and Java Script.

How do I enable the CSS and Java Script of the HTML page within the container. Pls help.

Thanks

Yogesh

markusriedinger
Advisor
Advisor
0 Kudos

Hey Tony,

WPC keeps css and javascript within com.sap.nw.cssservice.

if you open and par file and add you css and javascript files with your own names under /dist/css and dist/script than you are able to request the stylsheet via the name you have given the files. Doing it this way makes sure that your old scripts are only loaded when they are neaded on the page and that each script/css is only added once to the html document produced by the page builder.

Please find an example how we do this on SDN search below:

// include css

IIncludeCssService cssService = (IIncludeCssService)PortalRuntime.getRuntimeResources().getService(IIncludeCssService.KEY);

List cssNames = new ArrayList();

cssNames.add("sdn_general");

cssNames.add("sdn_apps");

cssNames.add("sdn_search");

cssService.includeCss(request, cssNames);

Former Member
0 Kudos

Hi Markus,

I like to ask, I have investigate and found how to add a javascript to an xls but modifying standard SAP code, I don´t think this is an option because I will have to be alert if the portal administrator applies a new support package and then again I will have to modify this classes.

I have EP 7.00 SP 18, How can I add a javascript to an xsl in WPC without modifying standard SAP classes?

Regards,

Juan Gonzalo Duque

Former Member
0 Kudos

Hello if anybody is interested I have found how you can reference a javascript in WPC. Just create a method in an XSLTHelper, this method should return the <scripts> tag with the link info and you are done. That's it.

Regards,

Juan Gonzalo Duque

Former Member
0 Kudos

Could you elaborate Juan please ?

Thanks a lot.

Former Member
0 Kudos

Tony -

I have not tried this but...

Maybe you could put the stylesheet either in the same folder as the html doc is in, or in a path that the html recognizes?

For instance, the html references the stylesheet in ../css folder which is on the same level as the html folder?

I am not sure what the portal would do, since I assume it tries to use one of the portal css files as well when rendering the html inside the portal?