Project

General

Profile

Adding dynamic external stylesheet

Added by Saif Rehman almost 8 years ago

Hi,

I can't figure out how to add a new dynamic external(or inline) stylesheet to an application. I want to create a new WCssStyleSheet for each template which may be modified during the session.

Please suggest a solution.


Replies (6)

RE: Adding dynamic external stylesheet - Added by Koen Deforche almost 8 years ago

Hey,

I'm not sure I follow exactly, but it sounds like you want want to have a separate .css file complementing each template, that you can do using several calls to 'WApplication::useStyleSheet()'

Koen

RE: Adding dynamic external stylesheet - Added by Saif Rehman almost 8 years ago

By dynamic stylesheet I meant a WCssStyleSheet object that can be used to add and remove Css rules

To add, its not important if its an external or internal stylesheet

RE: Adding dynamic external stylesheet - Added by Saif Rehman almost 8 years ago

If I pass WCssStyleSheet& as the argument to WApplication::useStyleSheet(), Wt gives me an error saying that the WCssStyleSheet must have a valid link. I made an issue about this earlier and you told me I can use WResource but I couldn't understand how can I use WResource for such purpose

RE: Adding dynamic external stylesheet - Added by Koen Deforche almost 8 years ago

Saif,

You can easily add and remove style rules from the (single) internal stylesheet?

app->styleSheet().addRule®

app->styleSheet().removeRule® // or delete r

Regards,

koen

RE: Adding dynamic external stylesheet - Added by Saif Rehman almost 8 years ago

That is possible but on the event that the style is to be reloaded or changed, using removeRule on each and every rule can be difficult and using WCssStylesheet::clear() would remove built in Wt rules along with the rules I've added. I do believe that multiple inline stylesheets can be made/modified in HTML but Wt doesn't allow it. Can I request this feature?

RE: Adding dynamic external stylesheet - Added by Koen Deforche almost 8 years ago

Hey Saif,

I understand and yes, that would be possible.

Koen

    (1-6/6)