Pages

Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

06 September, 2023

Hacky way to open XM Cloud Pages App from Content Editor using Sitecore PowerShell

When a content author is using Content Editor and want to use Pages to edit the pages, author can go to XM Cloud Apps Dashboard and then open the Pages App and then navigate to the appropriate item in the tree. In order to minimize the steps for the content authors, a simple hack in the content editor can help content author to open the Pages with appropriate item directly by click of a link. 

A page with Layout will have option to open it in Pages by clicking here hyperlink.

Sitecore PowerShell Extension is again helping here to set it up. Thanks to Adam Najmanowicz | @adamnaj / Michael West | @michaelwest101 for their effort to develop and release SPE for the community. 

  1. Create a new Module with Content Editor Warning integration point
  2. Go to the module and find Warning script library under Content Editor Warning item
  3. Create new PowerShell Script under that item and name it as Pages.
  4. Add the script with the below code.

Script to enable this feature:


In order to enable this feature only to the items where page layout is present, in the Enable Rule field, add ''where the item has a layout' rule. 



That's it. 

Points to remember:
  • This hacky will enable this option for all the pages where layout is present. In case if your use case is complex, then appropriate rule should be applied. 
  • The Pages link will open in another tab of the same browser. It is assumed that user is logged in to Sitecore Cloud Portal so that pages will automatically login and redirect to the selected item. 
  • Remember - This may not work for some complex Site grouping (have not tested it) but hoping Sitecore to add similar feature to open Pages from Content Editor out of the box 😊

17 January, 2023

Sitecore PowerShell - All Page Layout Data Report

Recently, for a migration project, I have been mostly working on Sitecore PowerShell to create reports and content exports. One of the ask from the client is to find out the unique set of pages with certain renderings in a template. So, the solution is to get the list of renderings of the page and find out the number of occurrences of each rendering. By which we can plan for bulk content export on those pages alone and leave the rest for manual migration. 

The below PowerShell script will help you to choose a root folder and it will export the data as below. 


You may consider this as a base script, and you should be able to make use of RenderingDefinition properties to group the component based on your need in line 49. Refer line 53 to 73 for the RenderingDefinition properties. 

Once we got the data, we used the Excel Pivot chart to group the results by Template Name and Layout.






20 December, 2022

Sitecore PowerShell - Expand Rich Text Links

First blog after submitting MVP Application 🙂 

In order to transform links in HTML to friendly URLs, you can make use renderField pipeline or Sitecore LinkManager ExpandDynamicLinks() method. 

There are cases where you would need to expand the HTML with friendly URLs as part of the Sitecore PowerShell report. In this article, you can see some examples on how this can be done using PowerShell and also, this can be used as a reference to run other pipelines in Sitecore PowerShell. 

Option 1: Using Pipeline

Option 2: Using LinkManager

Option 3: Custom Method

In case if you have any custom logic, you can add it as a method and call it via PowerShell. 


07 December, 2021

Sitecore PowerShell - Get All Sitecore Users With Basic Properties

Saving the handy script to get all the Sitecore Users with basic properties like Is Admin, Is locked out, email address etc. 



17 September, 2021

Sitecore PowerShell - Create a report with all referenced items by Lookup Items

In case if you have a list of lookup items and you would like to get a Sitecore PowerShell report of all the referenced items in Sitecore, you can make use of the below script. Also this script demonstrates the usage of PSObject by which you can create custom object and render it in the output window. This approach is using Link database and rebuilding the link database helps you to get the most accurate results. 

With PSObject, you can merge two different object and create a new custom object which can be used for rendering the results. Instead of using multi-dimensional arrays, this can be a better approach. 




blockquote { margin: 0; } blockquote p { padding: 15px; background: #eee; border-radius: 5px; } blockquote p::before { content: '\201C'; } blockquote p::after { content: '\201D'; }