Monday, December 27, 2010

Disable Sitecore User Account on Creation

When Creating a new User in code via the CreateUserWizard or simply by calling Sitecore.Security.Account.User.Create() the user is approved by default.
To alter this behavior you will need to get the user and update the IsApproved field.

If you are simply using Sitecore.Security.Account.User.Create() then you just need to do the following:

                    // Create a new user in the system
                    newUser = User.Create(userName, password);

                    // Since we just created the user they should not be approved yet.
                    MembershipUser user = GetMembershipUserByUserName(userName);
                    user.IsApproved = false;
                    Membership.UpdateUser(user);

If you are using the wizard here is the event code.

Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles CreateUserWizard1.CreatedUser

        ' Set Account to IsApproved=False
        Dim Usr As MembershipUser = Membership.GetUser(Me.CreateUserWizard1.UserName, True)
        Usr.IsApproved = False
        Membership.UpdateUser(Usr)

    End Sub

I got this information from a forum post about
How to send confirmation email to newly registering user via CreateUserWizard

If you found this article useful be sure to pass it on. If you have any tips, tricks or resources you would like to share with the Guild please email them to sitecoreguild@outlook.com

Friday, December 10, 2010

Configuring Custom User Profiles Properly

When it comes to custom user profiles, Sitecore is very flexible but sometimes that comes at a price. The description of setting up custom user profiles is straight forward in the documentation and as long as you only wish to access the properties in code it works great, however if you wish to access the properties from the database level you will need to add a few extra entries to the web.config.

STEP 1: Set up the Custom User Profile as documented in the Sitecore Security API Cookbook available on the Sitecore Developer Network

STEP 2: Make note of the custom properties you created and open the web.config. Search for "SC_UserData" Add items similar to this item below the existing SC_UserData item. Change the data type and field name to match the fields you added.

STEP 3: Read the following article to see how to get the aspnet profile properties from SQL Server

STEP 4: Create your user in the admin once created edit the user and click change to set your custom profile. Add data to the fields and check if its appearing for in SQL

STEP 5: When you create a user in code you will have to add the custom profile to them. as documented in the Sitecore Security API Cookbook available on the Sitecore Developer Network

If you found this article useful be sure to pass it on. If you have any tips, tricks or resources you would like to share with the Guild please email them to sitecoreguild@outlook.com

Tuesday, November 30, 2010

Page Editor not working with Multiple Sites Configured


For those configuring multiple sites in one Sitecore instance. Here is a tip to save you hours of pain. Make sure your websites are listed below the out-of-box Sitecore site entries not above.

If you reverse the order then the page editor will throw an error complaining that Sitecore.UiUtil.GetHomeItem() cannot find the object when logging into sitecore from your domain. Eg. www.test.com/sitecore/login will not work properly but localhost/sitecore/login works.

Turns out the handler checks the entries starting at the top and stops at the first match.

This order works:



<site name="login" virtualfolder="/sitecore/login">
<site name="testing" virtualfolder="/sitecore/testing">
<site name="admin" virtualfolder="/sitecore/admin">
<site name="service" virtualfolder="/sitecore/service">
<site name="modules_shell" virtualfolder="/sitecore modules/shell">
<site name="modules_website" virtualfolder="/sitecore modules/web">
<site name="site1" hostname="sitecore.site1.com" virtualfolder="/">
<site name="site2" hostname="sitecore.site2.com" virtualfolder="/">

This order fails:

<site name="site1" hostname="sitecore.site1.com" virtualfolder="/" br=""><site name="mica" hostname="sitecore.site2.com" virtualfolder="/" br=""><site name="shell" virtualfolder="/sitecore/shell" br=""><site name="login" virtualfolder="/sitecore/login" br=""><site name="admin" virtualfolder="/sitecore/admin" br=""><site name="service" virtualfolder="/sitecore/service" br=""><site name="modules_shell" virtualfolder="/sitecore modules/shell" br=""><site name="modules_website" virtualfolder="/sitecore modules/web" br="">

Hope this saves you some time and/or frustrations. If you have any tips, tricks or resources you would like to share with the guild please email them to sitecoreguild@outlook.com


Monday, November 29, 2010

How you can accomplish user driven site design by letting them select different CSS files or skins.

A co-worker of mine (Vlad) found this amazing article that shows you how you can accomplish user driven site design by letting them select different CSS files or skins.

The Power of Sitecore Separation Of UI and HTML

The concept is very similar th the ASP.NET Themes and Skins approach but this article explains how to do it in Sitecore.

If you have any tips, tricks or resources you would like to share with the Guild please email them to sitecoreguild@outlook.com and we will post them here.

Wednesday, November 24, 2010

Sitecore Maps - Google Map Integration

Need to integrate Google Maps with Sitecore. Here is a module to start you off.
https://marketplace.sitecore.net/Modules/G/Google_Maps.aspx?sc_lang=en

Here is the Install Video Tutorial

Thanks Sean McLean for providing this tip. If you have any tips, tricks or resource
you would like to share with the guild please post them on twitter referencing @sitecoreguild or email them to me at chris.williams@readwatchcreate.com

Sitecore - Getting Started Tips

Last night was the Toronto Sitecore Users Group meeting and I noticed there are were a lot of people just starting out with Sitecore. I figured it would he helpful if our first Sitecore Guild blog post assisted some of those beginners. If you have any additional tips for beginners feel free to comment on this post.

1) Take the Sitecore Training. If you have not been trained
on Sitecore, you will miss a lot of key concepts that will
hinder the success of your project. I know from experience.

2) Set up Sitecore to support multiple domains at the start.This will help you later when you want another site to share content.

Planning for shared content across sites will force you into the mindset
of shared content and code. This will help you on future projects too.

NOTE: In newer versions of Sitecore use an app.config file for each site to store the site mapping and other site specific settings. This will simplify upgrading.

Configuring Multiple Sites / Configuring Sites in web.config File

Read Watch Create has developed a free MultisiteQuickStart. If interested email chris.williams@readwatchcreate.com


3) Remember not all data needs to be in the CMS. Sometimes
data such as billing information do not need version control
or publishing rules. It is better to leave these items in
the database where they belong.

4) Wildcard content items are your best friend.
You may run into situations where you have content that is not in the content tree but you still want friendly urls not query strings.
It may not live in the CMS either because of tip 2 or because the data is coming from an external source

The solution is to place a * node below a node to accept all urls below it. Then instead of parsing a query string you would parse an url
for the data.

Here is the link and a brief note on wildcard nodes:

Sitecore Avoiding Query String In Dynamic Url

5) Resource Strings are content.
Store all your static string in the Content Tree as ResourceStrings.
This is a shift from standard .net where your resource strings would be
compiled in a resource file. By doing this, resource strings can be changed
by a content editor. Additional languages, in most cases would not require a recompile.

UPDATE: Check out this blog post for more information on the Resource String Module in the Sitecore MarketPlace

6) Keep common functionality together.
In the database, layouts, sublayouts, renderings exist in different nodes in the site but
In the physical folders, if you keep all the items related to a given folder you can more easily
package them up for another project. You never know when you can reuse a component.

I set up my physical folders as follows:

components\classes
components\dataproviders
components\Layouts
components\SubLayouts
components\Renderings
components\webcontrols
components\{modulename}\classes
components\{modulename}\dataproviders
components\{modulename}\Layouts
components\{modulename}\SubLayouts
components\{modulename}\Renderings
components\{modulename}\webcontrols
{sitename}\\classes
{sitename}\\dataproviders
{sitename}\\Layouts
{sitename}\\SubLayouts
{sitename}\\Renderings
{sitename}\\webcontrols

This keeps all the general items together, the module specific and the site specific in their proper places.

7) Find it before trying to build it.
Sitecore developer love to share. Through trac and the Developer Network you will find a wealth of shared source you can simply use.

UPDATE: Sitecore MarketPlace provides a vast amount of modules and developer starting points to help you get started on development rather than starting form scratch.

You can also find cookbooks that will tell you step by step how to accomplish common tasks. Unless you are implementing
something really specific, you are likely to find
a solution with source code that will either solve your exact problem or at least are a good starting point.

http://sdn.sitecore.net

8) Get Help from others.
If you are doing your first Sitecore project, don't be afraid to partner up with someone who has already done one. Sitecore gives you the illusion that it is easy to start a site but there is an initial learning curve. A partner that has been through even a single project could
help you avoid common pitfalls that could save you lots of time on your project.

9) Pay it forward.
When working on your solutions, if you do have to write a custom module but feel its generic enough to help other developers later. Share it.
The more we share the stronger Sitecore gets and the more productive we get as a community.

10) Connect with other Sitecore Developers.
A good way to do this is through going to the User Group Meetings, joining the Sitecore Facebook Groups and connecting to each other
on various Social Networks to share.

11) Check out the Sitecore QuickStart Blog Series
I have recently started a blog series called Sitecore QuickStarts.  This series provides a step-by-step guide through setting up your Sitecore development environment, your Sitecore Instance and guide you on your way to a successful implementation.

Twitter is underrated as a knowledge base. The Toronto Sharepoint Users Group developed the concept of placing @TSPUG on posts. Instead of posting where they were, they posted a quick comment or question and a link to answers.

I have started up a twitter account for the Sitecore Guild at https://twitter.com/SitecoreGuild
Please connect on twitter and when you find cool things for sitecore post them and be sure to include @SitecoreGuild in the post so we can all find them.

I will be collecting some of them regularly and sharing them here with the guild as well.

If you have any tips, tricks or resources please share them on twitter, comment on a post here or email them to me at chris.williams@readwatchcreate.com

Friday, October 22, 2010

Welcome to the Sitecore Guild

Welcome to the Sitecore Guild.

This blog is designed to contain various Tips and Tricks to help you with your Sitecore development projects. Since there is a lot you can do with Sitecore, sometimes it can be overwhelming knowing the best way to do something. Hopefully this will
help you with some of projects you are working on.

If you know any Tips, Tricks or resources for Sitecore let us know and we can add them to this blog. Please email them to chris.williams@readwatchcreate.com and we will post them.