Skip to main content

Posts

Sitecore PowerShell Script to create all language versions for an item from en version

  We have lots of media items and our business wants to copy the data from en version of media item to all other language versions defined in System/Languages. This ensures that media is available in all the languages. So, we created the below powershell script to achieve the same -  #Get all language versions defined in System/Languages $languages = Get-ChildItem /sitecore/System/Languages -recurse | Select $_.name | Where-Object {$_.name -ne "en"} | Select Name #Ensuring correct items are updated by comparing the template ID  $items = Get-ChildItem -Path "/sitecore/media library/MyProjects" -Recurse | Where-Object {'<media item template id>' -contains $_.TemplateID} #Bulk update context to improve performance New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) { foreach($item in $items){    foreach($language in $languages){ $languageVersion = Get-Item -Path $item.Paths.Path -Language $language.Name #Check if language versi...

Export Sitecore media library files to zip using SPE

If you ever require to export Sitecore media files to zip (may be to optimize them), SPE (Sitecore Powershell Extension) has probably the easiest way to do this for you. It's as easy as the below 3 steps -  1. Right click on your folder (icons folder in snap)>Click on Scripts> Click on Download 2. SPE will start zipping all the media files placed within this folder. 3. Once zipping is done, you will see the Download option in the next screen. Click Download Zip containing the media files within is available on your local machine. You can play around with the images now. Hope this helps!! Like and Share ;)

New Features in Sitecore 10 : Is it Worthy?

Finally Sitecore 10  is out and all the Sitecore developers are going crazy at this moment, especially the MVPs :P LinkedIn has flooded with Sitecore 10 blogs about the first installation experience, the introduction of new features etc. So I got curious ( like w asnt 9.3 launched a while back.. )  and, when got a chance, deep dived into the Sitecore 10 Release Notes to understand what the newer version brings to the table for developers. Here is the list of Sitecore 10 features which I believe still makes it worthy in content management ecosystem - Infrastructure-as-code - Sitecore 10 officially supports Docker, Kubernetes and new Sitecore-provided image repositories. This is really going to speed up on-boarding process for new developers into the project. So, Infrastructure-as-code enables the local setup to be source controlled (like code). New members have to setup the local repository and run few commands to setup their local instance. What's even greater is that th...

How to push items linked in rendering data sources to next workflow state in Sitecore

Workflow implementation is important for content governance. When content author updates a page in Sitecore experience editor, Sitecore notifies content author to submit the page to push it to next workflow state.  But what about the rendering data sources present on the page. Do they get pushed to next workflow state or not?  Sitecore does push the rendering data source items present on page to next workflow state if you have the below setting set to true in your configs (which is true by default Sitecore 8.2 onwards) -  <setting name="WebEdit.AffectWorkflowForDatasourceItems" value="true" patch:source="Sitecore.ExperienceEditor.config"/> However, that's not all. Some of the rendering data sources may be dependent on other items (we will call them linked items), especially for container renderings (which act as container for other data items). There is no setting in Sitecore OOB that can push the linked items to next workflow state. Content auth...

Check for lock on Sitecore Item

A page in Sitecore consists of multiple renderings with multiple data sources. Content authors need to acquire lock on a page to edit the page. When content authors save the component and submits it to next stage in workflow, Sitecore makes a check whether the context user has enough rights and the lock on the item (data source or page) to push it to next workflow. This is needed to make sure that the content author doesn't push an item that is not locked by it to next workflow. This is done using the below condition -  if (item.Access.CanWrite() && (!item.Locking.IsLocked() || item.Locking.HasLock())) This condition is useful when we are building a customization related to workflow processing or experience editor's inline editing functionality.