Posts

Sitecore Content Hub - Using Transformations on our Sitecore site

Transformations are a very important (and often ignored) feature, it basically lets you crop images on the fly and set the quality of images, without the need of creating custom public links. This is Sitecore's documentation related to Content Hub Transformations , however, how do we actually use these from a Sitecore site?  The short answer is you can't use Transformations using the Sitecore Connect for Content Hub connector. I have talked to Sitecore Support and they added a feature request so that public links inserted from the connector support transformations (reference number 518659).  In the meantime, what we can do, is add the transformations programmatically (I know, it's not the best) but if we want to leverage Content Hub Transformations on our Sitecore sites that's the only thing we can do for now. Sitecore support recommended using something like this in code:  Sitecore.Data.Fields.XmlField imageField = Sitecore.Context.Item.Fields["image"]; str

Sitecore Tip: Content Author minimum roles

 At a bare minimum, you want your content authors to have these OOTB roles:  sitecore\Sitecore Client Advanced Publishing sitecore\Sitecore Client Designing sitecore\Sitecore Client Authoring You should also have custom roles to further classify your content authors, e.g.:  Site Owner (Content Author "admin" for a specific site)  Workflow Approver/Reader (to push/approve items through workflows) etc

Sitecore | Coveo - Using a Sitemap source that hits a sitemap.xml not publicly accessible

Image
I'm using a Sitemap source on one of my Sitecore implementations because of specific needs of the project where using the Coveo for Sitecore Connector is not an option. This short post outlines the steps to allow Coveo hit a sitemap.xml that is not publicly accessible and that uses an internal certification authority to issue the cert used by the site (which are normal things on lower environments like DEV, QA and UAT).  You will see that the first time you create the Sitemap source it will fail because the sitemap.xml is not publicly accessible, you will get something like this:  In order to fix this issue, whitelist the appropriate IPs:  https://docs.coveo.com/en/1831/index-content/ip-addresses-to-allow-list Once you've whitelisted this IPs you might also get a different error, similar to this one:    This error can happen because the certificate is not valid or because the certificate authority is not trusted by Coveo, luckily there's an easy fix for that. You will need

Sitecore Content Hub - Approved Asset Email

Image
 Today I am going to show you how you can have Content Hub send emails to users that belong to a certain user group when an asset is approved.  There are a few steps that need to be followed to accomplish this:  Create an Email Template Create a user group Create the script Create the action Create the trigger So let's get started. There's currently no way to create email templates using the Content Hub graphical interface, therefore, we will use the REST API to do this.  We need to authenticate ourselves to make further calls using the API:  POST: https://{hostname}/api/authenticate Body: { "user_name":"YourContentHubUsername", "password":"YourPassword" } The response will be something like this:  { "token": "b9xxxfeac7fe41234544286e27f5xxxx" } Once you have the token, you can create the email template by using the entities endpoint:  POST: https://{hostname}/api/entities Header:

Sitecore Content Hub - Custom Action/Trigger to assign Asset Types automatically

Image
Assigning Asset Types is usually a manual task that is performed when an asset is created. However, we can define some rules so that the Asset Types are automatically assigned based on a condition. Today I want to show you how easy it is to accomplish this by using a custom Trigger/Action. This is something we can define for types of assets that are continuously uploaded to Content Hub. In my specific scenario, I want to automatically assign the Asset Type depending on keywords existing on the file name as follow: 1. If the file name contains the "sow" keyword, assign the SOWs Asset Type 2. If the file name contains the "contract" keyword, assign the Contracts Asset Type The first thing we need to do is create our custom  Script :   The code we are going to use in this script is the following:  using Stylelabs.M.Base.Querying; using Stylelabs.M.Base.Querying.Linq; using Stylelabs.M.Framework.Essentials.LoadOptions; using Stylelabs.M.Sdk; using Stylelab

Sitecore Content Hub - Custom Trigger/Action to clean an Asset's title

Image
Today I want to show you how easy it is to modify the properties of an asset using a custom Trigger/Action. In this specific scenario, we are going to clean the asset's title to follow certain naming conventions when the asset is created. The naming conventions that we are going to enforce are:  1. Replace empty spaces with hyphens  2. Replace underscores with hyphens  3. Remove special characters  4. Use only lowercase letters The first thing we need to do is create our custom Script :   The code we are going to use in this script is the following:  using Stylelabs.M.Sdk; using System.Net; using System.Net.Http; using System.Text; using Newtonsoft.Json; using System.IO; using System.Text.RegularExpressions; var assetLoadConfiguration = new EntityLoadConfiguration() { PropertyLoadOption = new PropertyLoadOption("Title"), RelationLoadOption = RelationLoadOption.None, CultureLoadOption = CultureLoadOption.Default }; var assetI

Sitecore - Animated SVGs

 For versions prior to Sitecore 8.1 update 2 some gymnastics needed to be done in order to support SVGs (you can refer to https://cmsxperience.com/2016/03/31/render-svg-images-in-razor-with-sitecore/). For later versions, that support comes OOTB. However, there might be times where we need to display animated SVGs, and those animations don't always work when the SVGs get displayed inside a <img> tag. This post is a modification to the blog post linked above, we will update the code so that our SVGs can be animated and can be available on image search:  public static MvcHtmlString RenderSvg(this HtmlHelper helper, string imageSrc, string imageAlt, string className) { if (string.IsNullOrEmpty(imageSrc)) { return new MvcHtmlString("<!-- No Image to display -->"); } return !imageSrc.Contains(".svg") ? new MvcHtmlString($"<img src='{imageSrc}' alt='{imageAlt}' clas