Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Changing webpart configuration in templates? View modes: 
User avatar
Guest
support-internetgeeks.co - 3/17/2009 10:20:31 AM
   
Changing webpart configuration in templates?
Hi,

I’d like to apologise in advance if this is a very basic problem that everybody knows how to resolve.

I have a template which is shared across multiple pages on a site. The template contains has an image applied to a particular div using a background image defined within a stylesheet. This works fine. The problem is that the image needs to change depending on the page that the user is looking at. We originally (and rather naively) tried to add a “Head HTML Code” webpart to the template with some css which changed the background image. Obviously however as the webpart was applied to a shared template, the background image was the same across all pages. The only solution that we can think of is to include some JavaScript in the template which changes the image depending on the URL. This however doesn’t seem like a very “clean” way of approaching the problem.

Basically we want a template which is shared across multiple pages, but each page includes a different piece of CSS to change an image.

Have we attacked this problem incorrectly? Or does someone have a solution?

Thanks in advance.


User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 3/17/2009 11:17:35 AM
   
RE:Changing webpart configuration in templates?
Hi,

I would recommend you to create custom macro (http://devnet.kentico.com/docs/devguide/appendix_a___macro_expressions.htm) and use this custom macro in your template layout which would generate your div tag with class according to the current alias path or according to current URL. Then you need to specify several CSS classes with different background images in your web site stylesheet.

Best Regards,
Miroslav Remias