Cross Browser testing using SuperPreview for Internet Explorer

by Aboo Bolaky 24. September 2009 07:52

Let's face it. Although I'm no designer, I do feel sorry for my fellow colleagues when I hear them complain about the rendering on some specific browser(s).

It gets harder when testing against IE6 for example. They normally use IE6 VMs to perform testing.  There are three major drawbacks of this approach:

1: WHERE IS THE IE6 VM? Is it on the local machine? Is it on the network? Is it on a Virtual Server that no one has admin rights to? Does the IE6 VM have a meaningful name .. Imagine having 10 VMs locally and having to boot each one to see if IE6 is present !!

2: Loss of password for Logging into VM. (just because the last person who logged in just decided to change the "usual" password to his/her cat's name and not telling anyone about it..and he/she is most propbably off sick when we need to do testing)

3: VM gets copied across network onto physical machine. Transfering 6-10 GB to your computer and hosting the VM locally. Another designer comes along and does the same thing. We now have 2 VMs on 2 different machines that serve the same purpose. Let's not entertain the idea of having both VMs running simultaneously !! A whole range of IP Address/Name resolution conflicts arise. :)

Microsoft Expression Web SuperPreview for Windows Internet Explorer

This tool allows us to view a page in different IE versions. This eliminates the use of glorious VMs for testing. Well done Microsoft !

You can download Microsoft Expression Web SuperPreview for Windows Internet Explorer here

Description

"Expression Web SuperPreview for Internet Explorer is a stand-alone visual debugging tool that makes it faster and easier to migrate your sites from Internet Explorer 6 to Internet Explorer 7 or 8. With Expression Web SuperPreview for Internet Explorer, you can ensure that your Web sites work correctly in Internet Explorer 8 while also maintaining compatibility with earlier versions of Internet Explorer.

Expression Web SuperPreview for Internet Explorer shows your web pages rendered in Internet Explorer 6 and either Internet Explorer 7 or Internet Explorer 8, depending on which version you have installed on your machine. You can view the pages side by side or as an onion-skin overlay and use rulers, guides and zoom/pan tools to precisely identify differences in layout. You can even compare your page comp to how the targeted browsers render the page.

Expression Web SuperPreview for Internet Explorer not only shows a high-fidelity rendering of how pages will look on different browsers, but it also identifies the element's tag, size and position, applied styles, and location in the DOM (Document Object Model) tree so you can quickly fix the error. "

Expression Web SuperPreview for Internet Explorer is a standalone, free application with no expiration and no technical support from Microsoft. 

Note:

If you wish to have the ability to debug pages both in IE and Firefox flavours in a single application, go for Microsoft Expression Web. You can download a 60-day trial copy here

 

Tags: ,

.Net | Applications | Freebies

Best way to parse HTML content

by aboo bolaky 23. September 2009 08:26


I'm going to keep this short and simple..rather short actually.

There is no better way to parse HTML other than using HtmlAgility Pack.

It's a lot simpler than Regex..which is a BIG no no!!

 

Tags:

.Net | Asp.Net | Freebies

SEO Friendly Urls in Sitecore -Remove spaces in Url (3)

by aboo bolaky 11. August 2009 06:33

It's the third time I'm writing on this particular topic (The EncodeNameReplacements element in the web.config). Articles 1 and 2  have had their importance in building SEO-friendly links in Sitecore.

Double Encoding in Urls

Whilst doing some routine administrative tasks in sitecore, I noticed that some links were no longer working. I was pretty sure that those links were working before I did a publish. :( Back to the drawing board.

As outlined in Articles 1 and 2, I was using

<replace mode="on" find=" " replaceWith="-" />

in my web.config. It was working fine when sitecore items were having names like "Camera one" (->url: camera-one.aspx), "Camera one two three" (->url: camera-one-two-three.aspx) etc...

However, if an item name has a character that has already been defined in my EncodeNamesReplacements section, Sitecore throws you back on the Item Not Found page. In my situation, I had renamed the Sitecore Item :"John Doe" to "John-Doe" (lame administrative task...I KNOW) . The effect of this is that when the user clicks on the John-Doe.aspx, he/she is redirected to the default "Item Not Found" sitecore page. A careful look at the url has revealed that Sitecore was trying to request an item with a name of John--Doe and consequently failed.

Solution

or hack (for some people)

If you are using a specific character to get rid of spaces in url, you need to make sure that a cms user will not be able to create an item name having that character in. Easy way to factor this in is to include your character in the InvalidItemNameChars element in the web.config. In my implementation, I've changed that setting to :

<setting name="InvalidItemNameChars"
	value="\/:?&quot;&lt;&gt;|[]-/>

 

and that did the trick :)

Tags: ,

.Net | Applications | Sitecore

Very Cool CSS Message Boxes for different message types

by Aboo Bolaky 31. July 2009 07:12

Janko Jovanovic has written a very nice article about ways to display different types of messages using CSS. The messages outlined are of the following types

  • Information messages
  • Success messages
  • Warning messages
  • Error messages
  • Validation messages

 

I believe what makes the article really stand out is the fact that he walks you through the css implementation as well. We're bound to display these types of messages on any web application we develop, so, please have a look at what he's achieved.

Tags:

Freebies | The AByss | Tips & Tricks

Implementing Sitecore Extranet login on a website

by aboo bolaky 30. July 2009 08:02

Here's the situation. You are about to implement a password protected area on your website. Let's assume that the general site structure looks like this

Pages below General and Products are accessible to everyone, whereas pages under Members should only be visible to authenticated/logged in members. I will first briefly outline the steps required to get this problem implemented using ASP.NET. Later on, I'll move onto it's equivalent Sitecore Solution.

Using ASP.NET

  • Implement Forms Authentication and set login url in the web.config.
  • Implement Login control and decide where to retrieve and store login credentials (in web.config or database)
  • In the web.config, add a Location Path pointing to the Members folder (Deny anonymous , allow authenticated users )
  • This is all about it really...(as far as I remember..) ...

In Sitecore, it's a different ball game.

In addition to adding the loginURL to the form authentication section (important if you use the loginview control to show the login page), you will need to  add the  "loginPage" attribute to the site which is defined by your extranet domain (normally, it's called "website" )

	
<sites>
 .....
	<site name="website" virtualFolder="/" physicalFolder="/" 
		loginPage="/General/Login.aspx"
  ....
</sites>

 

The LoginPage attribute is not something new here..It has always been there..(e.g. the shell website has already a loginPage set), but i did not know what was its purpose . Thanks to Chris Wojciech, I've discovered how to use this existing functionality in the web application.

The addition of Location path in the asp.net-only model is analogous to denying read access to the Members folder (+descendants) in Sitecore.

 

Once you perform a site publish, you can see the effects straight away.

If you've already signed in, you will be able to view /Members/View My Account.aspx.

If you're an anonymous user and access  /Members/View My Account.aspx, you will be presented with a default page that Sitecore serves in case access is denied due to security privileges.

http://mywebapp/sitecore/service/noaccess.aspx?item=%2fmembers%2fview+my+account&user=extranet%5cAnonymous&site=website

 

Quick Fix :

The page served in this case is called noaccess.aspx. The good thing is that this can be altered by changing the value of the "NoAccessUrl" attribute in the web.config.

If we set  "NoAccessUrl" to "/General/Login.aspx", we end up in this situation

http://mywebapp/general/login.aspx?item=%2fmembers%2fview+my+account&user=extranet%5cAnonymous&site=website

 

Recommended Solution

The nag in the above quick fix is that sitecore internally adds 3 QueryStrings to the url ( item, user and site). If we compare this to the normal ASP.NET solution, we would have ended up with only 1 querystring, which is the ReturnUrl.  Our goal is to follow the asp.net solution as close as possible. This is where Chris comes in..

Rolling out your own Security Resolver

Chris extended the HttpRequestProcessor class in order to intercept the request ,check if the user requesting the sitecore item has appropriate rights. If that is not the case, the user is redirected to the login page, with the appropriate ReturnUrl QueryString. Please go check the code out on his blog at http://blog.wojciech.org/?p=64 

The processor should then be plugged in the web.config, before the definition of the ExecuteRequest processor.

 

<processor type="Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel"/>
<processor type="Sitecore.Pipelines.HttpRequest.LayoutResolver, Sitecore.Kernel"/>
<processor type="MyWebApp.Pipelines.MyOwnSecurityResolver, MyWebApp"/>
<processor type="Sitecore.Pipelines.HttpRequest.ExecuteRequest, Sitecore.Kernel"/>

 

If you now try to access a protected page as an anonymous user, you'll end up on the login page (but this time, the ReturnUrl parameter has replaced the 3 built-in sitecore url parameters)

http://mywebapp/general/login.aspx?returnUrl=/members/view%20my%20account.aspx

Result :)

Tags: ,

.Net | Applications | Sitecore

LoginView control not working when logging out from Sitecore extranet domain

by aboo bolaky 29. July 2009 06:19

Let's not re-invent the wheel and make use of the ASP.NET 2.0 LoginView control to generate Login/Logout actions for the Sitecore extranet domain.

We have our LoginView control (very simplistic example given here) in a sublayout.

<asp:LoginView ID="loginView" runat="server">
	<AnonymousTemplate>
	  Welcome Guest <asp:LoginStatus runat="server" LoginText="Login" />
	</AnonymousTemplate>
        
	<LoggedInTemplate>
	  Welcome <%= Sitecore.Context.User.Name %>.
	  <asp:LoginStatus runat="server" LogoutText="Logout"
	   LogoutPageUrl="/" LoginText="Login" LogoutAction="Redirect" />
	</LoggedInTemplate>
</asp:LoginView>

LoginView Control Caveat

The LoginView control "magically" knows the login page url. This is specified by the LoginUrl attribute in the FormsAuthentication section of the web.config. This is not to be confused the LoginPage attribute (from the sites section). I had to modify my web.config to

 <authentication mode="Forms">
   <forms name=".ASPXAUTH" cookieless="UseCookies" 
		loginUrl="~/General/Login.aspx" />
 </authentication>

Erractic Behaviour when logging out

I did not experience any problems when logging in .i.e. the control did what is was supposed to do (display sitecore username and Logout Link). HOWEVER, when I pressed the Logout link, I always got redirected the Sitecore Layout page instead. I did spot similar behaviour with ListViews in Sitecore (also documented by Paul George and Mark Cassidy, where its events were not being fired at all. I've made the following change to my web.config and that solved the problem :)

<typesThatShouldNotBeExpanded>
   <type>System.Web.UI.WebControls.Repeater>/type>
   <type>System.Web.UI.WebControls.DataList>/type>
   <type>System.Web.UI.WebControls.LoginView>/type>
</typesThatShouldNotBeExpanded>

 

A similar problem that relates to the  typesThatShouldNotBeExpanded tag has also been documented on SDN

Tags: ,

.Net | Applications | Sitecore

Creating a Publishing Context Menu Item in Sitecore Content Editor

by Aboo Bolaky 26. July 2009 07:58

The more I think about this, the more I realise that this should be a built-in feature in Sitecore : To have a publish option whenever you right-click on any sitecore item.

Publishing Messages in Sitecore 

Fortunately, Sitecore is flexible enough. By doing a few customizations in the Core database, you can get a decent result. Before we tackle the WYSIWYG actions, we need to know the commands that Sitecore understands in order to launch the appropriate Publish window.

item:publish(id=$Target)

This is basically doing an Item publish. You have the option of publishing sub items as well. Once the publish is finished, you can see the publishing statistics.

system:publish

This brings up the publish window. This is the default screen when you hit Publish -> Publish Site (from the Ribbon)

 

item:publishnow

After having done this publish, you are not able to see the publishing stats..

  

Publish Operations and Messages

To summarize what's being said earlier, this picture shows how each menu item is related to the corresponding message.

Customizing the Context Menu

Switch to the Core Database and browse to the "/sitecore/content/Applications/Content Editor/Context Menues/Default" folder and create a new Menu item  ( Template Path : /sitecore/templates/System/Menus/Menu item). You can re-order existing menu items to your liking. For your new menu item, choose a display name (in my case , its "Publish Item"), an icon and finally the message (in my case, I've used item:publish(id=$Target)). All you now have to do is to switch back to the master base and view the result. Simple !!! :)

 

Tags:

Sitecore

Automatic Publishing in Sitecore

by aboo bolaky 26. July 2009 07:02

Sitecore DOES support Automatic Publishing. However, there are not many instances where you would want Sitecore to automatically perform a publish.

The values to change reside in the web.config, right where you have definitions for the scheduling and agents

<agent type="Sitecore.Tasks.PublishAgent" method="Run" interval="00:00:00">
	<param desc="source database">master</param>
	<param desc="target database">web</param>
	<param desc="mode (full or incremental)">incremental</param>
	<param desc="languages">en, da</param>
</agent>

 

I guess that a value of "00:00:00" for the interval attribute does disable automatic publishing. If you set the value to (say..10 minutes) "00:10:00", you will notice that after 10 minutes or so, changed items from the master database will be copied over to the web database.

Automatic publishing is useful where you have integrated external datasources in sitecore (using Data Providers) and where there needs to be a predefined process that synchs the external data to the web database. For the automatic publishing to work in this particular situation, you must have had created a new database entry (with a reference to your data provider) in the web.config.

Sitecore Data Providers....hmmmmm...that's upcoming.... :)

Tags: ,

.Net | Applications | Sitecore

Programmatically skip publishing of item(s) in Sitecore

by aboo bolaky 23. July 2009 05:43

Scenario

Assume that you have a set of items (say..Product items) (sitting anywhere within the /sitecore/content..) based on a specific template. The requirement here is that

"A Product cannot be published if one of its fields (ProductID) isn't populated."

Background

To achieve this, we need to hook into the publish:itemProcessing event in the web.config. This event gets triggered every time an item is published. The general steps involved in this situation are:

  • Create a class with a method that adheres to the EventHandler delegate signature. Whenever you initiate a publish operation in sitecore (be it smart publish, incremental or full publish), the method will be called (depending on how many items that need to be published)
  • Modify the web.config to subscribe to ItemPublishing event

ItemPublisher Class

namespace Test.Events 
{
	public class ItemPublisher
	{
	   public void CheckProcessing(object sender, EventArgs args)
		{
		  ItemProcessingEventArgs theArgs = args as ItemProcessingEventArgs;
						
		  Item currentItem = theArgs.Context.PublishHelper.GetSourceItem(theArgs.Context.ItemId);

		  if ((currentItem != null) && (currentItem.Paths.IsContentItem))
		  {
			  //Template ID of item on which selective publishing is to be applied
			 if (currentItem.TemplateID == new ID("{9C9A2F3D-652A-4490-AB57-E9F1B4D5BF05}"))
			  {
				 Job currentJob = theArgs.Context.Job;
				 JobStatus currentJobStatus = currentJob.Status;

				 if (String.IsNullOrEmpty((currentItem.Fields["Product ID"].Value)))
				  {
					currentJobStatus.Messages.Add(String.Format("Item :{0} has not been published since it has no Product ID", currentItem.Name));
					theArgs.Cancel = true;
					return;
				   }
			  }
		   }
		}
	}
}


Line 7:
Cast the standard EventArgs class to ItemProcessingEvent. This is important since it gives you the possibility of retrieving details of the items being published.

Line 9: Retrieve the item being published.

Line 11: The check for "currentItem.Paths.IsContentItem" is important since we only want to check for content items. Since publishable items sitecore vary from templates,standard values, renderings... we do not want to check for the condition in ALL items.

Line 14: If the template of the current item matches the id of the Product template, then we're back in business.

Line 16 - 21: Find the reference to the current Job (and JobStatus)  being executed in the publish pipeline. If the item's field is empty, add a message to the JobStatus.

Line 22: Abort the publish operation of the current item. I don't think we require the return statement after that. Publishing will then resume for the next item in the publishing queue.

Web.Config Change

Locate the publish:itemProcessing event in the web.config. Hook up the new handler to the event.

<event name="publish:itemProcessing" 
help="Receives an argument of type ItemProcessingEventArgs (namespace: Sitecore.Publishing.Pipelines.PublishItem)" >
   <handler type="Test.Events.ItemPublisher,TestApplication" method="CheckProcessing" />
</event>

Let's put it to the test

That's all to it really. If you now  initiate a publish operation and one of the Products has an emtpy Product ID, you will end up with this (if you click on "Click here to see additional information" on the last screen of the publish wizard.)

Items Skipped = 1 (.i.e Camera item has been skipped during the publish process since it has no ProductID). If you switch to the web database, there will not be any "Camera" item. 

Result... :)

Tags: ,

.Net | Applications | Sitecore

Filter Duplicates in MS Excel 2007

by Aboo Bolaky 21. July 2009 06:41


Forget the flimsy conditional formulae you had to use in order to filter duplicates in Excel 2000-2003.

Excel 2007 makes it a lot easier.

You just need to highlight the column you want to remove duplicates from, navigate to the Styles Ribbon, then Conditional Formatting -> Highlight Cells Rules -> Duplicate Values. You then only need to choose which color to apply for duplicate cell values..

et voila !!!

Tags:

The AByss | Tips & Tricks

Tag cloud

Flash Player 9 required.

About Me

I wish I could write something here..
//TODO: ElaborateMe