shared and client specific css ans js

In My coldBox app I have shared code and client specific code. I espetially looking for css and js. So I have shared code that I share througth Virtual directory in IIS.

I have the interceptor which determine which Layout get what css AND js. (shared code). The problem is that each client may have its own css how can I accomplish this scenario.

Please advice

Does anybody know how to do this ?

Thank you

Hi Erik,

When you say client do you mean different http clients like iphone, android, web browser, etc or do you mean a client as in company_a, company_b?

Nolan

Yes. Client means different Application that uses shared code and it also have local code

Okay.

Well there is no reason why you can’t reference external assets in two different locations from within your layout.

Take a look at the addAsset function in the HTMLHelper pluging - http://wiki.coldbox.org/wiki/Plugins:HTMLHelper.cfm#addAsset

In each application you can simply add the addAsset code in your handler and this should populate the tag dynamically. This assets could be stored in your IIS path (/JS/) or your local app path (/includes/js/)

Hope this helps

Nolan

I do use addAsset in my loadRenderProperties function. And Layout is using properly. I also Create a virtual directory for /includes where I have my js and css.

But the problem IS if I am in my new app for example would l like to apply a new style sheet my interceptor is not happening

It might be because you have an IIS mapping to /includes/

I think you should leave that to be relative to each app and use only the /js/ for shared mappings

Nolan

well. What IF I want for example the first page to look different but the rest of the page the same. That why I want to create a custom specific style

Could you not control that through CSS styling in the views?

i.e views/home.cfm has a style called class=“home”
views/page2.cfm has a style called class=“page2”

and then each custom CSS file could have a class for home and page2 with different styles?

sounds like this is more controlling CSS and not ColdBox related

Nolan

But what if am using external Layout and I need to change the background color for client1 but client2 would still have a default

this is getting hard to follow without seeing code.

are you using a separate css files for client 1 and 2? If so then you can do as I indicated below.

Nolan

There are a number of ways you can do this, but the most common approach that I have used is dependent on how you have designed your application.

So here is the question that we would need to ask you, how is this setup. Is the core application shared across all the domains you are using or do you just want one part of the code shared.

In the past I have used a core application code that is shared amongst all the domains that I have, I then in the application.cfc use code to identify which database will then be used and then set the application name to reflect this. From here you can then use an interceptor or other means to then lock what gets accessed.

In my case I also use a skin system that not only defines the look and feel for each site, but I also use different handlers views that are then based on that skin. This achieves two things, the first is that it keeps code that shouldn’t be shared such as CSS/JS files although there are times when these can be shared as well. So I have a common area that these can be loaded from in the normal shared application and the views for each skin, this was designed well before the introduction of modules and can still apply to core code in this method as well.

The concept here is that when the application is requested the url is checked, then the external locations are then changed to reflect the code aka handlers, etc to be loaded. I have been meaning to blog about this for a year or so now but never got around to doing that, but I would be happy to share more on how I do it.

I think there is a post in here explaining more on how I did this, although it might be about 12-16 months old the principle is still the same.

Regards,

Andrew Scott

http://www.andyscott.id.au/

SO I got addAsset to work now the problem is foolow. My shared includes I reference in by creating a virtual directory, but my local css file can not be found because it is trying to use virtual directory to find that file . What should I do ?

With the way I do it, it doesn’t require a virtual directory. But it also assumes that all the domains will use the same core application code, and that is your core application and not ColdBox itself.

Regards,

Andrew Scott

http://www.andyscott.id.au/

with my layout I have under shared folder styles directory. The same directory I have in client . SO in order for me to use includes from shared I set the virtual directory on the server. So now I can not see my styles