Archive for Code

FCK Editor Revisited – Adding a Custom Link Style

// September 19th, 2007 // 2 Comments » // Code, Web

I’ve had a few questions/comments on using Custom Styles with FCK Editor, so here’s a style that I created that will format any link you apply it to as a red button that changes color on mouse over.

Add this CSS to the fck.css and portal.css files in you PORTALS folder.

/* Both variations --a.color-- and --span.color a--
    are needed to handle DNN's span applications
    not being consistent */

.red_button, a.red_button:link, a.red_button:visited,
 span.red_button a, span.red_button a:link,
 span.red_button a:visited {
        font-weight: bold;
	font-size:10px;
	color: #FFF;
	background-color:#C00;
	padding:4px 8px;
	text-decoration: none;
	border-top: 1px solid #DFDFDF;
	border-left: 1px solid #DFDFDF;
	border-bottom: 1px solid #333;
	border-right: 1px solid #333;
	}

a:hover span.red_button,
span.red_button a:hover {
	background-color:#900;
	border-top: 1px #31557f solid;
	border-left: 1px #31557f solid;
	border-bottom: 1px #666666 solid;
	border-right: 1px #666666 solid;
	text-decoration:none
}

Be sure to add the following to the fck.xml file, to append the style to the menu in the FCK editor.

<Style name="red_button" element="span">
  <Attribute name="class" value="red_button" />
</Style>

Hope this helps, post any questions in the comments.

Source Chart Extension for Firefox

// July 26th, 2007 // No Comments » // Code

Just found a new Firefox Extension that’s quickly become a favorite. The View Source Chart extension works similar to a “View Source” command, but formats the page code in easy to read, color-coded blocks. It’s great for finding tags or code that are causing rendering problems or other issues. When debugging a site, you may not know exactly what you’re looking for, but with the nice hierarchy Source Chart provides, it’s easy to spot the item that’s out of place.

DotNetNuke = Cheeky Monkeys

// May 30th, 2007 // No Comments » // Code

Version 4.5.2 of DotNetNuke was released on May 29, 2007. Since I’m still heavily developing the site redesign for work in DotNetNuke, I downloaded the upgrade and installed it. It was a simple enough upgrade and worked flawlessly (as far as I can tell).

One thing did bug me. The SEARCH feature added two radio buttons next to the text area for the search, allowing users to search the site or the web. The web search uses Google (of course) and it even comes pre-filled with the DotNetNuke Google AdSense Client ID. This “feature” wasn’t in any of the preview releases, so it’s definitely like they tried to sneak that one in.

To disable the web/site search feature, you have to edit your skin file (it really should be an admin configurable feature). Just add the following, bold code to your search call:

< dnn:SEARCH runat="server" id="dnnSEARCH" showWeb=”False” showSite=”False” />

If you want to use your own Google ID, just locate the file at: admin/skins/App_LocalResources/Search.ascx.resx and change the client=pub-9770992166002654 to your own Google AdSense ID.

Using a Custom CSS File in DotNetNuke For FCK Editor

// May 17th, 2007 // 5 Comments » // Code

I’ve been working on implementing DotNetNuke at work for a few weeks now. After finally getting the hand of skinning DotNetNuke and building a custom skin that mimicked the look of the design provided by Marketing, I wanted to create a set of styles for formatting text. This would allow users to format text (and other elements) with a pre-set look and not have to use font-size, font-color and other outdated markup, thereby creating uniformity and smaller page/code sizes.

Well, after trying many attempts using the FCK Editor settings, I found the steps necessary to implement a set of custom CSS styles in DotNetNuke using the FCK Editor.

  1. Add your customs styles to portal.css in the portal root (Site Settings > Style Sheet) and save. These styles will be applied to your module text outside of the editor.
  2. Create a text file: FCK.xml. Here is where you will define styles to appear in the style list inside the FCK editor.
  3. Using the information in the FCK Editor Wiki help site, create your custom styles in FCK.xml. There should be an entry for each style you want to appear in the editor and in the order you want them to appear. See example below.
  4. Create a text file: FCK.css. These styles give the formatting to the styles you defined in FCK.xml so text in the editor will be formatted properly.
  5. Add your custom styles to FCK.css. This file contains ONLY your custom styles which are exactly the same as the custom styles you added to portal.css. There should be an entry for each style in FCK.xml you want to format.
    Using these lists limits the styles that appear in the editor to only those you want, rather than the long list of styles in portal.css.
  6. Upload FCK.css and FCK.xml to your portal root using the File Manger.
  7. Log in to your portal as Host and edit an HTML/Text module with the FCK Editor.
  8. Select “Show custom editor options”
    Select “Portal” for Settings Type.
  9. Expand “List of available styles for the editor”
    Select “URL” for Style list generation mode. Do not choose “Dynamic” or you will get a style list of garbage.
    Select “File” for Custom XML file, and select FCK.xml you uploaded to the root.
  10. Expand “Editor area CSS”
    Select “URL” for CSS Generator mode. Again, do not select “Dynamic”.
    Select “File” for Custom CSS file, and select FCK.css you uploaded to the root.
  11. Confirm “Apply custom settings to: Portal” and click “Apply”
    Close the FCK Editor custom options page and Cancel module editing.

  12. Refresh your browser with Ctl-F5 to force a refresh of the cache.

The list of styles should appear in the editor now. If you don’t see your styles and the formatting is not right, you might try deleting files in your cache. Also, check for mistakes in FCK.xml, FCK.css and portal.css. They must all be in sync and correct.

Here is a sample FCK.xml adapted from FCK:

<?xml version="1.0" encoding="utf-8" ?>

<Styles>
 <Style name="Image on Left" element="img">
  <Attribute name="style" value="padding: 5px; margin-right: 5px" />
  <Attribute name="border" value="2" />

  <Attribute name="align" value="left" />
 </Style>
 <Style name="Image on Right" element="img">
  <Attribute name="style" value="padding: 5px; margin-left: 5px" />

  <Attribute name="border" value="2" />
  <Attribute name="align" value="right" />
 </Style>

 <Style name="Title" element="span">
  <Attribute name="class" value="Title" />
 </Style>
 <Style name="Topic" element="span">

  <Attribute name="class" value="Topic" />
 </Style>
 <Style name="Custom Bold" element="span">
  <Attribute name="style" value="font-weight: bold;" />

 </Style>
 <Style name="Custom Italic" element="em" />
 <Style name="Title" element="span">
  <Attribute name="class" value="Title" />

 </Style>
 <Style name="Code" element="span">
  <Attribute name="class" value="Code" />
 </Style>

 <Style name="Heading H1" element="H1" />
 <Style name="Heading H2" element="H2" />
 <Style name="Custom Ruler" element="hr">

  <Attribute name="size" value="1" />
  <Attribute name="color" value="#ff0000" />
 </Style>

</Styles>

And corresponding FCK.css:

body, td {
font-family: Verdana, Sans-Serif;
font-size: 13px;
}

.Title {
font-family: Ariel, sans-serif;
font-size: 16px;
font-weight: bold;
color: red;
}

.Topic {
font-family: Ariel, sans-serif;
font-size: 14px;
font-weight: bold;
color: red;
font-style: italic;
}

.Bold {
font-weight: bold;
}

H1 {
font-family: arial, sans-serif;
font-size: 1.7em;
font-weight: bold;
color: #006699;
}

H2 {
font-family: arial, sans-serif;
font-size: 1.3em;
font-weight: bold;
color: #006699;
}

Those steps worked perfectly. Now I’ve just got to create the XML file to match the CSS file. I’ll go ahead and complain. It seems like there should be an easier way. Second, I don’t like the way it applies the styles. If I have a style “.red” (to make the text a specific shade of red) and I’ve got a style .bold (to make the font-weight:bold), DotNetNuke applies each one in a separate SPAN tag. I guess chaining CSS styles (span class=”red bold”) is too complicated.

Ugh! I guess this is the trade off. Moving the tedious task of menial updates to the users means uglier code underneath.

CSS Wild Card Selector

// May 11th, 2007 // 2 Comments » // Code

Playing around with DotNetNuke again today for work and the CSS implementation leaves a lot to be desired. For some reason (open source? – multiple contributors?) the CSS has hundreds of redundant definitions and the code base itself adds unnecessary or at least unwanted IDs or CLASS tags to everything.

Rather than have a single FONT-FAMILY declaration, it was declared on almost every style. Instead of BORDER, BORDER-RIGHT, BORDER-LEFT, BORDER-TOP, and BORDER-BOTTOM are used. It’s really insane. Almost every element of content gets assigned with CLASS=”Normal” and put inside a DIV with a uniqe ID ending with ModuleContent.

All of this rambling led to a cool way to assign CSS properties to certain elements based on Wild Card characters. This only works with Firefox, but if you’re trying get Firefox to display something differently than IE, it can be a big help.

/* all DIV tags with an ID ending in ModuleContent */
div[id$='ModuleContent'] {
border:2px #000 solid;
}

/* all A tags whose HREF attribute ends in .pdf */
a[href$='.pdf'] {
border:2px #000 solid;
}

Works great for debugging browser differences as well. Anyway, back to cleaning up the DotNetNuke default.css file. I’ve already got it pared down to 14k (from the original 18k).

Creating a DotNetNuke Skin

// April 20th, 2007 // No Comments » // Code

The decision was made at work to start moving content to a Content Management Systems. IT wants to move to mostly Microsoft products, so we chose DotNetNuke as the CMS platform.

I wasn’t overly excited. Much more info is already available for PHP systems like Drupal (or even WordPress), not to mention the size of their development community.

Anyway, DNN 4.5 seems to be a nice release. Much easier to install and I think I’m getting the hang of it. Thanks to Microsoft’s lack of standards support, a total CSS layout is out of the question. DNN likes to drop and add columns depending on where you’re at in the system and it requires a full page for the Inline Editor.

I did manage to generate a nice layout using a one row, three column table to hold my layout divs. This allows DNN to drop and add the columns without messing the formatting up.

This site has also be a great resource for skinning (creating a theme) for DotNetNuke. The Dreamweaver extension is also nice and gives you easy access to all the necessary placeholders for DNN content.

Appalachian State University Wants Firefox

// April 9th, 2007 // No Comments » // Code, Web

Well, at least one student does.

I understand where he’s coming from, really, I do. I’ve complained here (and at my old job) that things would be so much easier if Firefox were the default browser, instead of IE.

But, the reality of the situation is in most cases the switch cannot be made. I try to make everything I develop work just as well on Firefox as it does in IE, but not every developer follows those rules. Universities and businesses all use outside applications. Portal systems, ticket systems, Exchange servers. Many of those systems simply do not work well with Firefox.

Firefox doesn’t display all the functionality of MS Exchange when using it online. Firefox doesn’t support Window’s domain authentication (it send passwords in unencrypted text). Many web portals (especially academic ones) do not pass information correctly in Firefox.

That leaves the question, where does the responsibility lie. Should Firefox develop future versions with support for those features in mind or should application and software developers ensure Firefox support with future releases? There’s no easy answer, which means there is no easy solution. However, with Firefox (and other browsers) gaining users every day, it’s a question which will continue to come up.

Firefox Bookmarked Search

// March 30th, 2007 // No Comments » // Code, Web

Yet another reason to love Firefox, and one that I didn’t stumble across until recently.

If there are a few sites that you search regularly, you can add them right into Firefox and access them directly from the address bar.

For example, to search wikipedia, in the address bar, I’ll type w Spider-Man and Firefox will search wikipedia and pull up the results. Just right-click any search box on any site and select “Add a Keyword for this Search.” When the Add Bookmark window pops up, just enter in the Site Name and the Keyword you want to use to when searching.

You can download (right-click and “save as”) the 10-15 Quick Searches I have setup and import them into Firefox. You’ll be ready to go in no time. The ones I use the most, I have set to one or two letters. Simply type CTRL + L to access the address bar and enter your terms and off you go.

Here are the ones I use frequently:

allaboutduncan
Type “aad <search term >” to search allaboutduncan.com
Acronym Finder Quick Search
Type “acronym <acronym>” to look up what an acronym stands for in Acronym Finder.
Amazon
Type “am <product name>” to look up an item on Amazon.
Dictionary.com
Type “d <word>” in the addressbar to perform a dictionary look-up.
Drupal
Type “dru <search term>” to search Drupal.org
Ebay
Type “e <item>” to find something up for auction at Ebay.
Flickr Quick Search
Type “f <search term>” to search all the tags, titles and descriptions of images at photo-sharing site Flickr.
Froogle Quick Search
Type “froogle <product name>” to look up a product on shopping search engine Froogle.
Google Maps Quick Search
Type “map <address>” to get a Google map of a street address or location.
Google
Type “g <search term>” in the addressbar to perform a Google search.
Google Image
Type “gi <search term>” to find images that match using Google Image Search.
IMDB
Type “i <search term>” to search IMDB.com.
Ninja Search
Type “n <search term>” to search Ninja
Technorati Quick Search
Type “tech <search term>” to see what weblogs are posting about a topic.
Thesaurus Quick Search
Type “thes <word>” to find words with similar meanings in a thesaurus.
Wikipedia Quick Search
Type “w <search term>” to look it up in Wikipedia.
Youtube
Type “yt <search term>” to search YouTube

CSS Form Field Styling

// March 27th, 2007 // No Comments » // Code

I managed to stumble across two great examples of Form Field styling using CSS and JavaScript.

Ask the CSS Guy has a nice breakdown of how to recreate the Vox Registration form and it’s CSS Span hints. It’s pretty cool, but I think I’ll get rid of the <dd> and <dt> tags in the markup.

Also, Uni-Form is worth checking out as well. Using CSS, the form can easily be styled in one of two common ways. Great way to display a valid XHTML form in a variety of ways without changing your code.

Finally, Ill mention a Prototype Form validation set that I’ve been using for a while on work projects. I need to switch it over to jQuery,
but I’ve been lazy about it. I’ve created quite a few custom validators for it and the new release
makes it even easier to combine and change options on the form fields. I’ve not found something in jQuery that is as robust, yet.

Time Sensitive CSS Switcher

// March 12th, 2007 // No Comments » // Code, Web

Pretty cool tutorial / explanation on how to set your blog up to display a different CSS style / layout / background based on the time of day. I’ve done user selectable layouts and random images, but this is a creative idea and the related design fits perfectly with the idea.

read more | digg story