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

Burn ISO Images on DVD using ImgBurn

by Aboo Bolaky 13. July 2009 03:38

I just realised how easy it is to burn .iso files onto dvds. Previously, I used to have many issues with the various tools that were available out there..mainly because I was running a 64-bit OS. Now, on top of Windows 7 RC (x64), everything seems to be a lot easier.

ImgBurn

Supports a wide range of image file formats - including BIN, CUE, DI, DVD, GI, IMG, ISO, MDS, NRG and PDI.

Burns Audio CD's from any file type supported via DirectShow / ACM - including AAC, APE, FLAC, M4A, MP3, MP4, MPC, OGG, PCM, WAV, WMA and WV.

You can use it to build DVD Video discs (from a VIDEO_TS folder), HD DVD Video discs (from a HVDVD_TS folder) and Blu-ray Video discs (from a BDAV / BDMV folder) with ease.

Supports Unicode folder/file names, so you shouldn't run in to any problems if you're using an international character set.

Supports all the windows OS's - Windows 95, 98, Me, NT4, 2000, XP, 2003, Vista, 2008 and 7 (including all the 64-bit versions). It also nicely integrates with the context menu. 

 

AND, ABOVE ALL, IT'S FREE !!! ImgBurn Website

Tags:

Freebies | Tips & Tricks

The Sitecore Way

by Aboo Bolaky 9. July 2009 07:09

4 months since my last post. This should give you an idea of my hectic life as a software developer.  Build..Test.. Deploy.....Build..Test.. Deploy.. This seems to be the only thing that I have been doing lately and hasn't left me with any time to do anything else.

Things have got to change and NOW is the time :-)

Back in Febuary, I came accros a file (via some random Google Search about Sitecore) that outlined some good one-liners about building websites using Sitecore. At that time, I added the link to my favourites and didn't pay much attention to it. Now that I've accessed the link again (by mistake..), I realise that so many of those "guidelines" are correct. Unfortunately, I did not capture the author of the text file at that time. Here's the online version

The Sitecore Way

1) Think about the CMS users not just the Web site. The Sitecore Way.

2) Use XSLT to minimize code compilation for maintenance. The Sitecore Way.

3) Get better performance with ASP.NET user-controls.  The Sitecore Way.

4) Use an ASP.NET master for your layouts. The Sitecore Way.

5) Return Item ID for XSLT extension results. The Sitecore Way.

6) Avoid setting language in a request after the Sitecore pipeline. The Sitecore Way.

7) Use icons for your masters and templates. The Sitecore way.

8) Protect /sitecore as much as you can. The Sitecore way.

9) Cookieless is possible, but be careful. The Sitecore way.

10) It's very important to Organize the content structure correctly. The Sitecore Way.

11) Finalize design as much as you can before implementation. The Sitecore way.

12) Ask for design behavior specs not just content info. The Sitecore way.

13) Use file system for large files instead of media library. The Sitecore way.

14) Use source-control for new/changed files inside Sitecore. The Sitecore Way.

15) Please avoid inline C# code in XSLT. The Sitecore way.

16) Test renderings using the debugger ALWAYS. The Sitecore way.

17) Multi-site, multi-language, identify what the client needs. The Sitecore Way.

18) Globalization is easy with Sitecore...use it. The Sitecore way.

19) Create custom XAML apps for better experience. The Sitecore way.

20) Use Sitecore's security mechanism for other applications. The Sitecore way.

21) Be careful of data cache synchronization between two sites. The Sitecore way.

22) Remove default favico.ico or your client might yell at you. The Sitecore way.

23) To stage or not to stage. We say to stage. The Sitecore way.

24) Use Lucene.net if you can for site search...it's FREE. THe Sitecore way.

25) Disaster recovery plan: zipped Web site and DB backups.  The Sitecore way.

26) Minimize rendering URL parameters to keep an SEO-friendly site. The Sitecore way.

27) Dont' forget the robots.txt...just good Web practice. The Sitecore way.

28) Analyze secuirty by feature and content access. The Sitecore way.

29) Download the Enhanced Email Action, why not? The Sitecore way.

30) Content analysis should be a top priority. The Sitecore way.

31) Use nested templates but be careful. The Sitecore way.

32) Make life easy by using a sticky session load-balancer. The Sitecore way.

33) More than a CMS, it's an integration platform. The Sitecore way.

34) Get more value by integrating it with internal systems. The Sitecore way.

35) Deliver templates and masters early to  avoid content freeze. The Sitecore way.

36) Physical storage of data does not look like Sitecore XML. THe Sitecore way.

37) Ever used Sitecore Query to query the Sitecore XML?  It's cool. The Sitecore way.

38) Use the search in the Sitecore bar for a quick content search. The Sitecore way.

39) No gray desktop background or you might loose your cursor : ). THe Sitecore way.

40) Drag content items on the desktop to create a shortcut. The Sitecore Way.

Credits: Unknown Author

 

How many of these have you achieved????

 

Tags: ,

.Net | Applications | Sitecore | Tips & Tricks

Tag cloud

Flash Player 9 required.

About Me

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