Thursday, December 10, 2015

Sitecore EXM Message creation links are not responding

Sitecore version: 8.0 rev 150621
EXM version: 3.0 rev 150429

When I'm working with a Sitecore EXM module I experienced the email creation links are not working in the EXM. The links in the below image.



The reason for happening this is, some values and items required to EXM has been removed from the Core database.

1. To solve this problem, setup a vanilla installation of Sitecore using the SIM (Sitecore Instance Manager) tool. Read more about SIM from here.
2. Go to the instance's (website's) sitecore.
3. Change to Core database using the Sitecore Desktop.





4. Go to Content Editor --> Client --> Applications --> ECM --> Dialog Renderings 
Here is the place you can find the controls for dialog boxes links in the Sitecore EXM.

Find the following renderings:
a. OneTimeMessageRenderings
b. SubscriptionMessageRenderings
c. TriggeredMessageRenderings

5. Select each of them and do the following steps.

5.1. Go to 'Layout' section in the renderings item.

5.2. Go to View in the Sitecore ribbon and check 'Standard Fields' and 'Raw Values'.


5.3. The problem is with the 'Rendering' field.
Copy the 'Rendering' field value from your newly created Sitecore vanilla instance to this.

5.4. Do this for b and c also.

5.5. Save the changes.
When try to save there will be a warning message coming saying "The item "TriggeredMessageRenderings" contains broken links in these fields: - Renderings: "static" Do you want to save anyway?"



Ignore this message and click ok.

5.6. Go to EXM and test the links now. It should work.

CAUSE
The reason I assume for this problem is, I have remove the broken links in the Sitecore Core database using the removebrokenlinks.aspx which is provided by the Sitecore.
As you can see in the message, there are some broken links with these items.
So when I try to remove the broken links in the Core database using removebrokenlinks.aspx it removed these rendering values also.
So be careful when using the removebrokenlinks.aspx against the Core database.







Tuesday, December 1, 2015

Sitecore 8: Upgrade EXM 3.1 Update 1

In this blog post I'll explain how to upgrade the EXM to version 3.1 update 1.

Requirements:
1. Sitecore 8.0 rev. 150621 (Update-4) / Sitecore 8.0 rev. 150812 (Update-5).
2. Email Experience Manager 3.1.1 rev. 150811.update file.

You can download this from here. (You may require the permission to download this update).

1. Pre-Installation

1.1. Disable the following configuration files:
 Sitecore.EmailCampaign.config file.
 Sitecore.EmailCampaign.Speak.Server.Requests.config file.
 Sitecore.EmailCampaign.UI.config file.
 Sitecore.EmailCampaign.Dedicated.config file.
 Sitecore.EmailCampaign.Xtune.CD.config file.
 Sitecore.EmailCampaign.Xtune.Processing.config file.

1.2. Disable all scheduled tasks at the following locations:
 /sitecore/system/Tasks/Schedules/Email Campaign
 /sitecore/system/Modules/E-mail Campaign Manager/Tasks

NOTE: To disable the scheduled task, go to the task and clear the value in the 'Schedule' field in the item's Data section. (See image bellow)



1.3 Detached the Sitecore.EXM database (which is defined in the ecm.dispatch connection string)
NOTE: This is not available in Sitecore 7.5 and Sitecore 8.0. So if you are running on one of these versions you can skip this step.

1.4. If you are running on Sitecore 8.0 update 5 add the following configurations to your web.config file. (Else skip this step as well).

<dependentAssembly> 
   <assemblyIdentity name="MongoDB.Driver" publicKeyToken="f686731cfb9cc103" /> 
   <bindingRedirect oldVersion="0.0.0.0-1.8.3.9" newVersion="1.10.0.62" /> 
</dependentAssembly> 
<dependentAssembly> 
   <assemblyIdentity name="MongoDB.Bson" publicKeyToken="f686731cfb9cc103" /> 
   <bindingRedirect oldVersion="0.0.0.0-1.8.3.9" newVersion="1.10.0.62" /> 
</dependentAssembly>


2. Upgrade Installation

2.1. Go to the following URL.
http://<your_host_name>/sitecore/admin/UpdateInstallationWizard.aspx

2.2. Click 'Chose Package'



2.3. Select the package using the 'Brows' button. And continue by clicking on 'View package information'.


Then it will show you the package information.


Continue by clicking on 'Analyze and install the package'.

2.4. It is always better to analyse the package before install. Or you can directly click on Install.


If you select 'Analyze', it will show the details and click on 'Analysis results'.

This will show the problems with the analysis process. You need to look for red, blue and yellow signs.



2.5. Click on 'Install the package'.


2.6. You can check for the problems and if you feel ok you can close this page now.

3. Post-Installation 

After installing the update package, you should perform the following post-installation steps. Some of them can be already done for you. You just need to check every thing is ok.

3.1. Attach the Sitecore_Exm database to SQL server.
NOTE: You can find the file in the Data folder or, alternatively, in the Website\temp\ECM folder.

3.2. In the App_Config\ConnectionStrings.config file, add the SQL server connection string exm.dispatch
NOTE: Don't delete or overwrite the existing ecm.dispatch connection string because we need it to migrate the old data to the new database. (Migrate data from EXM monboDB to SQL database)

3.3. To migrate your existing email campaign data to SQL server, go to following URL.
http://<your_host_name>/sitecore/admin/MigrateCampaignData.aspx
If you don't have any data to migrate you can skip this step.

3.4. Now you can delete the old ecm.dispatch connection string in the /App_Config/ConnectionStrings.config file.

3.5. In the \App_Config\Include\EmailExperience\Sitecore.EmailExperience.Core.config file, replace the entire <ecmDataProvider defaultProvider="mongo"> section with the following section:

<ecmDataProvider defaultProvider="sql"> 
   <providers> 
      <clear/> 
         <add name="sql" type="Sitecore.Modules.EmailCampaign.Core.Data.SqlDbEcmDataProvider, Sitecore.EmailCampaign" connectionStringName="exm.dispatch"/> 
   </providers> 
</ecmDataProvider>

3.6. Remove the EXM httpHandler and handler sitecore_ecm_speak_request.ashx from the web.config file. (Simply delete the lines)

3.7. Remove the following files from all instances of EXM :
sitecore\shell\client\Applications\ECM\EmailCampaign.Client\Pipelines\UpdateMessagevariant\UpdateVariant.js
sitecore\shell\client\Applications\ECM\EmailCampaign.Client\Pipelines\UpdateMessagevariant

NOTE: Steps 3.5 and 3.7 might already done for you.

3.8. Your custom settings are not automatically ported to the new configuration file. If you have used any custom settings in the previous version and you want to apply them to EXM 3.1, make the necessary changes to the Sitecore.EmailExperience.ContentManagement.config file manually.

Ok, we are done with the installation.

4. Set the SMTP settings

In the Sitecore.EmailExperience.ContentManagement.config file set the smtp settings by changing the following configurations.

      <!-- SMTP server address (IP). -->
      <setting name="SMTP.Server" value="localhost" />

      <!-- Port number of the SMTP server. -->
      <setting name="SMTP.Port" value="25" />

      <!-- Domain for logging into SMTP server. -->
      <setting name="SMTP.LoginDomain" value="" />

      <!-- User name for logging into SMTP server. -->
      <setting name="SMTP.UserName" value="" />

      <!-- Password for access to SMTP server. -->
      <setting name="SMTP.Password" value="" />



Wednesday, November 18, 2015

Sitecore 8 - Document Manager is blank in Rich Text Editor

Environment: Sitecore 8.0 rev 150621

Sitecore Rich Text Editor allows to link a document to a link. So the idea is to download the linked document when the particular link is clicked.
To link the document you have to use the Sitecore Rich Text Editor (RTE). But when you trying to link the document using the Document Manager in the Sitecore RTE it is blank as bellow.



I have raised a Sitecore support ticket and this issue reported as a bug in Sitecore.

They have provided the following workaround to overcome this issue.

1. Open the /Website/sitecore/shell/Controls/Rich Text Editor/EditorPage.aspx file
2. Find the following text part and replace it:

MediaManager-ViewPaths="/media library"
TemplateManager-UploadPaths="/media library"

with this one:

MediaManager-ViewPaths="/media library"
DocumentManager-DeletePaths="/"
DocumentManager-ViewPaths="/"
TemplateManager-UploadPaths="/media library"

3. Clear browsers cache and try the issue again.
Let us know if you have any issue with the Document Manager.



Tuesday, November 17, 2015

SItecore 8 - Solve 'The model item passed into the dictionary is of type 'Sitecore.Mvc.Presentation.RenderingModel' error

When I work with Sitecore, I build Sitecore link databases to avoid some errors causing in our environment. But after building the core, master and web database links using the Sitecore Launchpad --> Control Panel --> Rebuild link databases I got the following error when I try to log in to the Sitecore back-end.

The model item passed into the dictionary is of type 'Sitecore.Mvc.Presentation.RenderingModel', but this dictionary requires a model item of type 'Sitecore.ExperienceAnalytics.Client.Mvc.Presentation.ExperienceAnalyticsLineChartViewModel'.

The reason for this issue is Sitecore does not clear the cache after it builds the link databases.
To solve this issue, do the following steps:
1. Login to the http://{your website}/sitecore/admin/cache.aspx
2. 'Clear all' cache.
3. Restart the website from IIS

But this a temporary solution.
I'm experience this issue time to time.
So when this error is throwing you have to redo the above steps.

Update

I created a Sitecore support ticket sine this error getting annoying and they provide a fix with some item changes. It include item changes in the core database.
If this problem arise in your environment I think it is better to raise a Sitecore support ticket with your databases.

Until Sitecore support come with a solution...

Don't worry, you don't have to be blocked with this.
In my case this error came in the Sitecore launch pad. So I was able to bypass the launchpad when I log in to the Sitecore by using the http://{website name}/sitecore/shell url.











Thursday, November 12, 2015

Sitecore 8: GeoIp not picking City, Region and Country

Environment: Sitecore 8.0 rev 150621

When we are testing our site to get visitor details, GeoIp does not tack City, Region and Country details of UK visitors. But visits received from Sri Lanka get the City, Region and Country details.

The reason for this is our QA visit the site from our internal network (the same network which our website is hosted).
Sitecore GeoIp does not track the City, Region and Country visits for the users coming from the internal networks.

To check this you can use an IP changing tool like Hide My Ass or Freedom.

Wednesday, November 4, 2015

Sitecore - Delete current version from an Item using Workflow Action

Current Environment: Sitecore 7.2 rev 140526

Requirement:
  • Need to remove the selected language from the item.
  • Need to remove it using the Sitecore Workflow Action 

Sitecore Step 1: Create a workflow action within the workflow which is set to that item template.

Create a workflow. (I used the default sample workflow).
You can find how to create the workflow action in sitecore cookbook: http://sdn.sitecore.net/upload/sitecore6/workflow_cookbook_a4.pdf

Sitecore Step 2: Provide Type String

Select the created workflow action.
In the Type String field provide the following details.
namespace.class_name, dll_name 

Do the following code for the class (.dll)

Coding:

     public class DeveleVersion
    {
        public void Process(WorkflowPipelineArgs args)
        {
            Item item = args.DataItem;
            
            Database db = Sitecore.Context.ContentDatabase;

            if (db == null || item == null) return;
            if (item.Versions.Count <= 0) return;
            using (new Sitecore.SecurityModel.SecurityDisabler())
            {
                item.Versions.RemoveVersion();
            }
            args.AbortPipeline();
        }
    }





Tuesday, November 3, 2015

Sitecore 8: Unable to add Enroll in Engagement plan save action to a Sitecore WFFM form

Environment: Sitecore 8.0 rev 150621

Whn I was working on Sitecore WFFM (Web Forms For Marketers) forms and save actions I got the following issue.
When I try to add Enroll in Engagement plan save action I got a Sitecore error saying "This action cannot be added. Your configuration does not support it."


This is happening because of 'Disable Analytics for this Page' setting in the Sitecore WFFM.
You can check this setting on the Advanced section in your WFFM form Content.



You can disable this setting by clicking on the 'Attributes' link.
Then go to the Settings section. Remove the check on 'Disable analytics for this page' check box.


Try to add the 'Enroll in Engagement Plan' save action. It will be added to the form save action list without getting the above error message.


Monday, November 2, 2015

Sitecore 8 - Check Item's created and last updated days

Environment: Sitecore 8.0 rev 150621

Sometimes you need to check when is a specific Sitecore item has been created or edited.
You don't have to worry about these things because Sitecore save these for you.

You can view item's following details:
1. Item created date.
2. User who created that item.
3. Revision of the item.
4. Last updated date of the item.
5. User who did the last update to the item.

To view the above details follow the following steps:
1. Go to the item you want.
2. Go to the 'View' section in the ribbon and make sure the 'Standard fields' check box is selected. (See image bellow)


3. Scroll down in the item's content section until you find the 'Statistics' section. Expand this and you can view the details mentioned above.


Wednesday, October 28, 2015

Sitecore 8: Sending reminder mails without knowing

Environment: Sitecore 8.o rev 150621

When I setup new instance on one of our production environment, I have experienced the following message on Sitecore log files.

ManagedPoolThread #14 11:24:06 INFO Executing email reminder task
ManagedPoolThread #14 11:24:06 INFO Parameters: <r><to>name@company.com</to><txt>Demo reminder</txt></r>
ManagedPoolThread #14 11:24:06 INFO Sending reminder mail (to: 'name@company.com', from: 'name@server.net', subject: 'Reminder from Sitecore')
ManagedPoolThread #14 11:24:06 INFO Using mail server: 'smtp.company.com'

When this message logged to the Sitecore logs it says there are some unwanted reminder mails are sent to the Sitecore content authors. 
The reminder emails sending are not expected by the content authors and they are usually outdated.

We have raised a Sitecore support ticket and their suggestion is to manually change the values which responsible for this in the database.


To change the values within the Sitecore database: 


1. Login to your website SQL Server.

2. Go to the website's Sitecore core database.
3. Select * From Tasks
4. Check the resulting table's 'Pending' column.
5. Check if there are any 1 's (Which means reminders are sending)
6. Change required values to '0' using the bellow query.
    Update [Tasks] Set Pending = 0; (This will make all the values to 0, so use whatever the where clauses you want and run the query.)


Monday, October 19, 2015

Sitecore 8 - System.ArgumentException: Directory does not exist. Parameter name: directoryVirtualPath

Environment: Sitecore 8 rev. 150621

When I work one of our projects. I have experienced the following error:

Directory does not exist.
Parameter name: directoryVirtualPath


NOTE: Get the latest Sitecore databases from your CI or Release environment which already installed the required Sitecore modules.

The error message describes there is a required directory (folder) missing in your solution.
If you have copied the Sitecore correctly this can be due to not coping a required Sitecore module.

Go to the config files of your solution to figure out what are the Sitecore modules that used in your solution.
Since the solution is not working and you can't access the Sitecore desktop to install modules, extract required module and copy the files and folders inside \package\files and paste to your website root.

Since your database has the required items of the Sitecore modules, copying the files of the module is just enough. 

This should do the work.

Monday, September 28, 2015

Sitecore WFFM - Add to Contact List save action not showing contact lists

Environment: Sitecore 8.0 rev 150621

Sometimes when working with the WFFM on Sitecore you might experience the following issue with the 'Add the contact to contact list' save action.


This is because of following:
1. You have no lists created.
2. You have lists but it is not visible in the List Manager.

To ensure this go to the 'List Manager'/


In my case, I have list created but my List Manager won't show me anything.

In this case, go to the Sitecore Control Panel and Select the 'Indexing manager' under the 'Indexing' section.
Select the 'sitecore_list_index' as bellow image.


Then click 'Rebuild'

After it is done, visit the 'List Manager' again. If you have created some list earlier, it must appear in here now as bellow.


Then go to your form's save actions. Select the 'Add to Contact List' save action. Go to Edit.
Then you can see your lists are appear on that save action.



Monday, September 7, 2015

Fixing Sitecore Licence Issue

When working with Sitecore you might face issues like bellow:

At this point your site will not be accessible and you can't run the showconfig.aspx as well.
If you know the location of the data folder (where Sitecore licence live) of your site, you can directly copy the new licence file to that location.

Sitecore default data folder is /App_Data/Sitecore.
But sometimes your website can have a config that override this location for a different location.
In a situation like that we can get the help of Sitecore Config builder. You can download and get to know more about this tool from here.

1. Download the Sitecore COnfig Builder and Unzip to a folder you like.

2. Get the App_Config folder and web.config file of your broken site to a preferred location. Keep the both App_Config folder and web.config file in the same folder.

3. Open Sitecore.ConfigBuilder.Tool.exe 


4. Click on 'Browse' and select the web.config from the location that you have save them.

5. Select 'Save files into the same folder' if you want (this is easier actually ;) ) and click on 'Save'.

6. This will create some couple of files on the location you ask to create.

7. You can find a file called showconfig.xml

8. Open it and find the following section:
<sc.variable name="dataFolder" value="{ Your data folder location }" patch:source="DataFolder.config" />

9. Go to that location. Make sure it has a licence file.

10. Copy your latest Sitecore licence file (copy and replace).

Your site will be now up and running. 

Thursday, September 3, 2015

Working with SItecore MongoDB databases

Sitecore introduce mongoDB on Sitecore 7.5 for handle their Sitecore Experience database (xDB).
When you working with Sitecore mongoDB you have to know how to backup and restore mongoDB databases.

Backup Sitecore mongoDB database

The simple way is to backup as dump.

Go to mongoDB folder/bin from command prompt.
D:\MongoDB\bin>

Backup single database to a different location
D:\MongoDB\bin>mongodump --out \{folder}\{folder}\ -db {database_name}

Ex- D:\MongoDB\bin>mongodump --out E:\backups\ -db mongo_old_db

Sometimes there can be an error like bellow:


Then use D:\MongoDB\bin>mongodump --out \{folder}\{folder}\ --db {database_name}

Read more on mongodump from here

Restore Sitecore mongoDB databse

You can rename the database if you want when restoring.

Go to mongoDB folder/bin from command prompt.
D:\MongoDB\bin>

Restore single database with a different name
D:\MongoDB\bin>mongorestore -d {new_database_name} {old_database_backup_path}

Ex- D:\MongoDB\bin>mongorestore -d mongo_new_db D:\backups\old\mongo_old_db

Read more on mongorestore from here

Read more on other backup and restore methods in mongoDB from here

NOTE: Always use folder paths and folder names without spaces and special characters.
Otherwise use the path within double quotes ("").

To view database tables and data in a graphical way, you can use a tool like RoboMongo.
Read and download RoboMongo from here.


Monday, August 31, 2015

Sitecore logs - How to find errors and issues

Environment - Sitecore 8.0 rev. 150621

Hi all,

If you worked as a pure .NET developer and you moved to work with Sitecore you will get the same problems as I had few months back from now.

"How am I going debug this ???"
"Where are the errors ??"
"How can I find the errors on my site and any function ???"

Those are my questions when I start Sitecore. Since Sitecore is a product and it uses it's own dll files to perform it's internal tasks we can't debug the classes inside the Sitecore like we do in a pure .Net project. But Sitecore provide a way to take you out from these troubles. Sitecore log files.
You can find these log files on your data_folder/App_Data/Sitecore/logs

Sitecore uses Apache's log4net to create log files. You can have a read on log4net from here.

There are 3 types of log files

1. Standard log (log)
This is the most common log. This log will log errors, warnings, information, etc according to your settings.

            Verbose log
This logging feature is disabled by default. This feature is designed to provide search index configuration and provide more rich and more detailed version of the problem. You can enabled this feature by removing the '.example' from the 'Sitecore.ContentSearch.VerboseLogging.config.example' cofig files inside the {your_site_folder}/App_Config/Include

* Verbose Log should enable only on special scenarios and never run long period of time specially on production environments. Since verbose logger would creates an extremely large log file, it can cause to a performance issue.

2. Crawling log (Crawling.log)
Track information about indexing operations. (I'll talk about Sitecore Indexing in latter session)

Following shows an example of  a crawling log.

11704 13:22:13 INFO  [Index=social_messages_web] Initializing SitecoreItemCrawler. DB:web / Root:/sitecore/social/Messages
11704 13:22:13 INFO  [Index=sitecore_analytics_index] Initializing TimedIndexStrategy with interval '00:01:00'.
11704 13:22:13 INFO  [Index=sitecore_core_index] Initializing IntervalAsynchronousUpdateStrategy with interval '00:01:00'.
11704 13:22:13 INFO  [Index=sitecore_master_index] Initializing SynchronousStrategy.
11704 13:22:13 INFO  [Index=sitecore_web_index] Initializing OnPublishEndAsynchronousStrategy.
11704 13:22:13 FATAL [Index=sitecore_web_index] Initialization of OnPublishEndAsynchronousStrategy failed because event queue is not enabled.

By default the Crawling log is set to output logs on 'INFO' level.

3. Search log (Search.log)
Shows queries that were generated and run.

Following shows an example for a search log.

3724 13:47:58 INFO  ExecuteQueryAgainstLucene (sitecore_analytics_index): type:contact - Filter :
3724 13:47:58 INFO  ExecuteQueryAgainstLucene (sitecore_analytics_index): type:contact - Filter :
3724 13:47:58 INFO  ExecuteQueryAgainstLucene (sitecore_analytics_index): +contact.contactid:a2a2d13f8603400d864c7914aadd593d +type:visit - Filter :

To get the full level details of the content search you have to enable the 'Sitecore.ContentSearch.config' and change the logging level to 'DEBUG'.

You can find all the configurations related to these log files in the <log4net> section of the web.config file.
According to the requirement you can increase or decrease the level of the log. The following provides the logging levels minimum to high.

  1. OFF - nothing gets logged 
  2. FATAL
  3. ERROR
  4. WARN
  5. INFO
  6. DEBUG
  7. ALL - everything gets logged

* Your log levels can be changed when you enabled the Verbose logging.

Sitecore will create logs for each day. If you want fresh logs on a day, you can restart the site from Microsoft IIS Manager. Then Sitecore will create logs with date and number. (ex- log.20150828.132211.txt)

* If you are still like to see the .Net errors on the page when you are testing you can turn off the custom errors on the web.config file.

Change <customErrors mode="On"  /> to <customErrors mode="Off"  />




Tuesday, August 18, 2015

Sitecore Web Forms for Marketers Save Actions: The action does not exist

Environment - Sitecore 8.0 rev. 150621

Sitecore Web Forms for Marketers Save Actions are used to provide functionalities which need to perform when a certain form is getting submitted.


When dealing with the save actions on Sitecore 8 there is an issue with the graphical interface on save action management. Therefore some save action which removed from the form can be still exist in the save actions raw values.
You can find this by checking on the Sitecore log files. If there is a such issue, in the Sitecore logs you can find a error similar bellow.

6092 05:46:44 WARN  Web Forms for Marketers : The '{D866FC78-08F5-4AAA-975C-26E991B1D881}' action does not exist

Follow these steps to find this save action exists.

1. Go to your Sitecore instance and go to Web Forms for Marketers, go to the form which throwing the error and turn on the 'Raw values' from the 'view' tab


2. Copy the value (xml) of the 'Save Actions' field of the 'Submit' section to a notepad.

3. Copy the Sitecore item. (according to the log message the item is - {D866FC78-08F5-4AAA-975C-26E991B1D881})

4. Find the copied Sitecore item on the notepad.
    If the item is found on the notepad you have to remove it from that xml.

    Remove unwanted save action from xml.

    4.1. Create a new form.
    4.2. Add the other save actions on your form to the newly created form.
    4.3. Copy the value (xml) of the 'Save Actions' field of the 'Submit' section of the newly created form.
    4.4. Paste it to the 'Save Actions' field of the 'Submit' section form that throwing errors.
    4.5. Do the required changes to the save actions.













Monday, July 27, 2015

Sitecore - Add Visual Studio Project to existing sitecore instance

Sitecore - Add Visual Studio Project to existing Sitecore instance

Hi,

Some of you have created fresh Sitecore instance for check some Sitecore functionalities like Web Forms For Marketers, Email Campaign Manager, etc.
Now If you wan't to add some extended capabilities or you want to add your code you have to create a Visual Studio Project to this existing Sitecore instance.

This is how you can do it.
I assume that you have a Sitecore instance. I have created a fresh instance as SitecoreFresh. (If you don't have one and if you want to try this out you can easily create a Sitecore instance using the Sitecore Instance Manager : Sitecore Instance Manager)

1. Open Visual Studio.
2. Go to new project. Under Visual C# section select ASP.NET Web Application.
3. Give Name, Location and Solution name as you desire.
4. From template selection section select 'Empty' and select the 'Web Forms' check box. (This is because the Visual Studio will add the required references to your project.). Select Ok.



5.  Go to the location you create this project.
6. Copy the .sln file and paste it inside the folder where your Sitecore instance root.



7. Go again to the location where you create the project (Step 5).
8. Go inside the folder which contain the website.
9. Copy the 'Properties' folder and '.csproj' file and paste it inside the website folder of your fresh Sitecore instance.
10. Double click on the copied .sln file on your Sitecore fresh folder.
11. Visual Studio will complain the project cannot be load. This is because the opened sln file is belong to the project that you created at step 4.
12. Remove the broken project from the Solution Explorer.
13. Right click on the solution at Solution Explorer and Add Existing Project.
14. Select the csproj file on your fresh instance folder and Open it.
15. This will load your fresh Sitecore project to the Solution Explorer.
16. Go to references and add the Sitecore.Kernal.dll. (Create a lib folder and copy the dll to that folder and get it from there).
17. Include the folder and files that you want in the project using the 'Show All Files' function in Visual Studio solution explorer.



Ok, we are all done here. You are good to go.



Thursday, June 4, 2015

Get Sitecore items (child items) inside Sitecore folder.

1. Create a class and create a method with your required assess method.

         protected Database Database
        {
            get
            {
                return Sitecore.Context.Database;
            }
        }

         protected Item GetItem(Guid id)
        {
            if (Sitecore.Context.Item != null && Sitecore.Context.Item.ID.Guid.Equals(id))
            {
                return Sitecore.Context.Item;
            }
            else
            {
                return Database.GetItem(new ID(id));
            }
        }


2. Get the folder item

            Guid folder_guid = new Guid("{Your-item-id}");
            var folder_item = GetItem(folder_guid);


3. Loop through the items inside that folder

            if (folder_item != null)
            {
                foreach (Item childItem in folder_item.Children)
                {
                    //Do your logic with  the childItem
                }
            }



Wednesday, April 29, 2015

Sitecore - Item language

Sitecore 'items' and 'languages'

Hi all, in this post I like to discuss some little things that you might like to know when you are playing with the Sitecore items and langues.

1. Get the languages of an item.

Item currenItem = (Get the current item to the variable) - The way of getting the item can be different the method you are using and the parameters.

                    Language[] langs = currenItem.Languages;

2. Get the  item versions of an certain language

                    foreach (var lang in langs)
                    {
                        var langItem = currenItem.Database.GetItem(currenItem.ID, lang);
                        var vers = langItem.Versions.GetVersions();
                    }

3. Get the fields of an item

                     latest.Fields.ReadAll();   //This will provide all the fields in the item
                     var fields = latest.Fields;

Hope this is useful.