Category: Tips & Tricks

Sitecore: 5 Simple Security Tips

Sitecore: 5 Simple Security Tips

This post is relevant to Sitecore solutions where user should login before accessing of user data. Below described 5 simple but important steps that should be taken into consideration to improve application security.

Continue reading “Sitecore: 5 Simple Security Tips”

Advertisements
Sitecore: Custom Friendly URLs

Sitecore: Custom Friendly URLs

Very often every Sitecore developer has faced with the following situations:

  • there is a shared content between multiple sites.
  • there is a content tree that shouldn’t be exposed outside

In such a case would be great to have ability to manage url that is returned by LinkManager.GetItemUrl(). In order to accomplish this there is a need to implement a custom LinkProvider and configure Sitecore to use it.

Continue reading “Sitecore: Custom Friendly URLs”

Sitecore: Hide fields from Content Editor

Sitecore: Hide fields from Content Editor

Very often every Sicore developer fas faced with the necessity of adding new fields for some particular template. And this task is pretty easy! After new field has been added it appeared in Sitecore Content Editor.

But let’s imagine the situation when there is a need to associate new field with a template and not to show it in Sitecore Content Editor for everyone by some condition or don’t show it for anyone at all.

Continue reading “Sitecore: Hide fields from Content Editor”

Sitocore: Customizing the Core

Sitocore: Customizing the Core

Once you decided to build the site the following most known difficulties be present during site’s construction:

  • Complicated business logic.
  • Significant number of stakeholders.
  • Need to support several cultures (even you never heard about some of them)
  • Plenty of content

Fortunately, Sitecore solves (or at least gives convinient way) most of them. But you should keep in mind that Sitecore is not a magic pillis, but it’s more than up to the challenge when it comes to building sites.

Continue reading “Sitocore: Customizing the Core”

Sitecore: How to import content with minimum effort

Very often (in testing perspective or vital necessity) there is a need to import data into the Sitecore. There are many tools that can be used for such purpose. But I want to propose you something very simple, something readily available, and yet something powerful and flexible enough to build a reusable component. In such a case I would use Sitecore Powershell Extensions.

Continue reading “Sitecore: How to import content with minimum effort”

Sitecore: Search for Items That Don’t Have Any Language Versions Using Powershell

Recently, I have faced with an issue using traditional Powershell commands. I was trying to identify items that did not have any associated language version. There are various ways of how an item can get to this state. I will not get into these cases here, because they are typically specific to the implementation. But, what is certain across all cases is that these items cause problems because they (and their descendants) don’t get published. This causes a lot of confusion between what you see in Experience Editor and on the front-end site – items are not the same.

The problem lies in the format of traditional Powershell commands which are require a -Language param to retrieve specific versions. I specifically needed to identify unversioned items, but it was not so simply:

  • If you leave the language param off, it will use “en” as the default choice
  • If you pass an empty string for this param, it will return all versions of items that have language versions.

That’s great, but I still had not udentifier the items without a language version. If you want to reproduce it, just create a new item, then go to the “Versions” tab and delete the current version.

Here comes the Powershell

Since I could not use Get-ChildItems to get my unversioned items, I had the idea to look for items that have a collective count of all language versions equal to 0. There is a wonderful method  that helps me to achive my goal – GetVersions. It receives at the input bool includeAllLanguages and returns an array of items. This is the perfect method to leverage since I can test for an empty count to determine if it’s one of the unversioned items.

# point this to the root of your website
$folder = "/sitecore/content"

# Where-Object clause could be combined with other filters
# like Name or Template to narrow results for something specific
$items = Get-ChildItem -Path $folder -recurse | `
Where-Object { $_.Versions.GetVersions($true).Count -eq 0 } | `
%{
[PSCustomObject]@{
"ID" = $_.ID
"ItemName" = $_.Name
"Item" = $_
"ItemPath" = $_.Paths.Path
}
}

# print out any results that were found
$items

I hope this work around will save you some time and frustration. As I mentioned, being able to identify these items is critical to resolving the conflict between what you are seeing in the Experience Editor and what is showing on the front-end site.

Enjoy!