Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

AspDotNetStoreFront
  Ads  
Aspose - The .NET & Java component publisher
 


  Sponsors  

Meet Our Sponsors

Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
AspDotNetStoreFront - E-Commerce by Design - The Leading ASP.NET shopping cart platform for developers!
SteadyRain
DataSprings - Great Ideas. Always Flowing.
R2integrated - formerly bi4ce
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Make it Hot! ( ...  Dynamic CSS Selector
Previous Previous
 
Next Next
New Post 6/13/2006 4:16 PM
User is offline Paul Schaefer
21 posts
10th Ranked


Dynamic CSS Selector 

We have a design that requires a new color scheme two times a month.  The color scheme applies to new tabs (a specific parent tab and its children) while all the rest of the previous tabs retain the previous color scheme. 

 

Specifically, we have a printed bi-monthly newsletter that changes colors.  The tab layout is Past Issues and the children of Past Issues are 1/1/2006, 1/15/2006, 2/1/2006, etc.  In this example 1/1/2006 has a unique color and so do all his children.

 

The skin layout is consistent issue to issue and the color scheme is made with background images via a CSS.  

 

The manual way is to make a new skin every month, I guess.  Then manually apply the new skin to the applicable pages.  Instead, I’d like to figure out a way to dynamically change the skin.css (equivalent) by page instead of creating new skins.  This way I’d only have to modify the CSS to look for different background images.

 

Or, better yet, change the directory of the CSS so I can have unique directories for all the corresponding images.  This way I wouldn’t have to modify the CSS but just have different images (same file names only the directory would be different).

 

Anyone have any experience with this?  Would it work to inject a unique css path in the page Header?  Is there a more automated way (module) to manage something like this? Is this a fantasy?

 

Thanks for any help.

Paul

 
New Post 6/13/2006 4:57 PM
User is offline Nina Meiers
1737 posts
www.xd.com.au
5th Ranked




Re: Dynamic CSS Selector 

I'm very much into theme and efficient use of skinning files -in fact I try to use as little as possible, and use CSS where possible and think globally about my designs and see where we can have common look and feel, as well as the ability to make small but important changes.  And I hate lots and lots of folders in my skinning directory when 1 will do the job with multiple css files to handle it.

It does take a bit of thought and I have a small article that covers understanding the css skinning hierarchy which is an important starting point.

You can in fact, if you're design is planned, simply rename the file, and give it another folder for images, do a copy and replace image locations, change a few colours and your skin should be completely rejuvenated to the new look and feel.

What you need to do is then apply the customised elements - eg.. the montage, text colour, whatever, to the individual css file - so it would look like this.

Issue01.ascx - Issue01.css (and that file would have it's own classes)

Issue02.ascx - Issue02.css (and that file would have it's own classes)

and so on.

And if you design the main global elements - eg.. font size, padding, overall look and feel - and keep that in the skin.css file - then you would have all the elements you need for a simple change.

I hope you understand this overview since you've grasped the crux of the concept of it.

Nina Meiers


Nina Meiers - XD Design - Professional, Ethical and passionate about DotNetNuke
Over 50 FREE DotNetNuke Skins

XD Design - xd.com.au by Nina Meiers
 
New Post 6/13/2006 7:36 PM
User is offline Nik Kalyani
706 posts
www.dotnetnuke.com
7th Ranked








Re: Dynamic CSS Selector 

This is quite simple with a little bit of Javascript. Basically you take advantage of two things:

1. The DotNetNuke URL Rewriter includes the tab name in the URL, and

2. Most modern browsers allow you to inject a stylesheet on-the-fly with Javascript.

The solution is to name all the child pages with a common prefix and use that prefix to dynamically inject a stylesheet that customizes the appearance of the page. With this approach, you have one skin that works one way for all pages, but works a different way whenever the page displayed has a name that begins with the designated prefix. (Note: You can give the page any title you wish; it's just the page name that has to follow a convention.)

For testing my solution, I created the following:

1. A skin named "Dynamic" with a single template named "Portal.ascx" and a stylesheet named "skin.css". The solution does not care about either of these names...you can use any names you wish.

2. In the "Dynamic" skin folder, I created sub-folders named "01012006", "01152006" and "01262006". In each sub-folder, I created a stylesheet named "overlay.css" with some styles that override definitions in "style.css". You can put any images specific to these styles in the same folder (or a sub-folder) since stylesheet URLs are always relative to the stylesheet file.

3. I created a page named "Past Issues" and set its skin to "Dynamic - Portal". I created child pages "ISSUE01012006", "ISSUE01152006" and "ISSUE01262006". I set the skin on each to be the same, i.e. "Dynamic - Portal".

4. I put the following code in "Portal.ascx" just below the last <%@ Register... statement:

<script type="text/javascript" language="javascript">
// <![CDATA[

function injectStyleSheet(prefix)
{
    var segments = location.href.split("/");
    var issue = "";

    for(var s=0;s<segments.length;s++)
    {
        if (segments[s].indexOf(prefix) == 0)
        {
            issue = segments[s].replace(prefix,"");
            break;
        }
    }

    if (issue != "")
    {
        styleSheet = "<%= SkinPath %>" + issue + "/overlay.css";
        if (document.createStyleSheet)
            document.createStyleSheet(styleSheet);
        else
        {
             var head = document.getElementsByTagName("head")[0];
             head.innerHTML += "<link rel=\"stylesheet\" href=\"" + styleSheet + "\"/>";

        }
    }
}

injectStyleSheet("ISSUE");

    // ]]>
</script>

That's about it. The code kicks-in whenever a page name begins with "ISSUE" (you can change this) is encountered and customizes the appearance.

Nik

 


Nik Kalyani
Co-founder/Director of Products & Strategy
DotNetNuke Corp.
Blog | Twitter | FaceBook
 
New Post 6/13/2006 7:39 PM
Online now... John Mitchell
3910 posts
www.snapsis.com
4th Ranked




Re: Dynamic CSS Selector 

Have a look at these blog entries, they should start you in the direction if not get you to where you are going.

 

http://blogs.snapsis.com/PermaLink,guid,105f8d79-ffbc-4859-836c-b747364fa59c.aspx

http://blogs.snapsis.com/PermaLink,guid,148f785b-3892-47ae-b969-0549aeb30b29.aspx


DotNetNuke Modules from Snapsis.com
 
New Post 6/14/2006 9:25 AM
User is offline Paul Schaefer
21 posts
10th Ranked


Re: Dynamic CSS Selector 
Wow!!! Great info and suggestions from all three of you.  Thank You!!
 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Make it Hot! ( ...  Dynamic CSS Selector
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


UK - DotNetNuke providers
UK providers of DNN module development and skin package design. Oxford Information Labs provides cost-effective solutions for businesses and organisations specialising in Skin design and bespoke module development.
www.oxil.co.uk
TronixSoft
Hosting for local businesses that want more from their websites.
www.TronixSoft.com
The Forerunner Network
The Forerunner Network consists of a group of Dynamic Website & Interactive Membership Portal hosting services that are managed by Forerunner Communications. Our services span a wide range of markets and enable individuals, organizations and businesses to build and manage dynamic, interactive portals and websites.
The Forerunner Network

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP