### Run Sitefinity .NET Core Renderer Application
Source: https://www.progress.com/documentation/sitefinity-cms/144/setup-with-sitefinity-cli
Starts the Sitefinity CMS .NET Core Renderer application. This command compiles and runs the ASP.NET Core application, making the renderer accessible.
```bash
dotnet run
```
--------------------------------
### Install .NET Core Renderer Templates with .NET CLI
Source: https://www.progress.com/documentation/sitefinity-cms/144/setup-with-sitefinity-cli
Installs the Sitefinity ASP.NET Core Renderer templates using the .NET CLI. This command downloads and registers the necessary project templates for creating Sitefinity CMS applications with an ASP.NET Core renderer.
```bash
dotnet new -i Progress.Sitefinity.AspNetCore.Templates::*
```
--------------------------------
### Install and Run Minimal Resource Package with npm
Source: https://www.progress.com/documentation/sitefinity-cms/152/resource-packages-net-core/install-the-minimal-resource-package
This snippet outlines the npm commands required to install the Minimal resource package and start the development watch process. It assumes Node.js is already installed. The 'npm start' command compiles frontend assets and watches for file changes.
```bash
npm install
npm start
```
--------------------------------
### Sitefinity CMS: Application Start Method Attribute (C#)
Source: https://www.progress.com/documentation/sitefinity-cms/152/custom-personalization-criteria-create-the-installer-class
Applies the PreApplicationStartMethod attribute to an Installer class, specifying a method to be called when the ASP.NET application starts. This is used to initialize Sitefinity CMS customizations.
```csharp
[assembly: PreApplicationStartMethod(typeof(Installer), "PreStart")]
```
--------------------------------
### Content-Security-Policy Examples for Sitefinity CMS
Source: https://www.progress.com/documentation/sitefinity-cms/content-security-policy-%28csp%29-http-response-header/csp-header-syntax-reference
Examples demonstrating how to configure the Content-Security-Policy HTTP header in Sitefinity CMS for common scenarios. These examples illustrate setting trusted sources for general content, scripts, and integrating third-party services like Google Analytics.
```text
Allow everything but only from the same origin
Put 'self' in Trusted sources for… -> Any content.
Only Allow Scripts from the same origin
Put 'self' in Trusted sources for… -> Scripts.
Allow Google Analytics, Google AJAX CDN and Same Origin
Put 'self' www.google-analytics.com ajax.googleapis.com in Configure Trusted sources for… -> Any content.
```
--------------------------------
### Install Sitefinity CMS via NuGet Package Manager Console
Source: https://www.progress.com/documentation/sitefinity-cms/144/install-sitefinity-in-
This snippet demonstrates how to install the Sitefinity CMS headless package using the Package Manager Console in Visual Studio. It specifies using all package sources and includes the '-IncludePrerelease' flag, which is crucial for certain versions. It also shows how to specify a particular version.
```csharp
Install-Package Progress.Sitefinity.Headless -IncludePrerelease
```
```csharp
Install-Package Progress.Sitefinity.Headless -Version 14.4.8100.0
```
--------------------------------
### Example .nuspec Dependency for Sitefinity Add-on
Source: https://www.progress.com/documentation/sitefinity-cms/111/add-on-upgrades-and-versions
This example demonstrates how to specify a dependency in a .nuspec file for a Sitefinity CMS add-on. It ensures the add-on is compatible with a specific minimum version of Sitefinity CMS and higher.
```xml
```
--------------------------------
### Install Project Packages and Run Next.js Renderer Locally
Source: https://www.progress.com/documentation/sitefinity-cms/cloud-saas/setup-the-project-for-local-development-next-js
These commands are used to install the necessary project packages for the Next.js Renderer application and to start the development server for local testing. This allows you to develop locally against the cloud-hosted version of the application.
```bash
npm install
npm run dev
```
--------------------------------
### Create New Sitefinity .NET Core Renderer App with .NET CLI
Source: https://www.progress.com/documentation/sitefinity-cms/144/setup-with-sitefinity-cli
Creates a new Sitefinity CMS .NET Core Renderer application using a .NET CLI command. This command initializes a new project with the specified project name and configures it to connect to a given Sitefinity CMS instance URL.
```bash
dotnet new sitefinity --project-name "YourProjectName" --sfurl "http://your.sitefinity.url"
```
--------------------------------
### GET Images API Example
Source: https://www.progress.com/documentation/sitefinity-cms/144/content-service-api
A sample snippet illustrating how to make a GET request to the Images API.
```APIDOC
## GET Images API
### Description
This is a sample snippet for making a GET request to retrieve images via the Sitefinity CMS Content API.
### Method
GET
### Endpoint
`///Images`
### Query Parameters
* **filter** (string) - Optional - Filter criteria for images.
* **take** (int) - Optional - Number of items to retrieve.
* **skip** (int) - Optional - Number of items to skip.
### Response
#### Success Response (200)
- **value** (array) - An array of image objects.
- **id** (string) - The unique identifier for the image.
- **url** (string) - The URL of the image.
- **title** (string) - The title of the image.
#### Response Example
```json
{
"@odata.context": "...",
"value": [
{
"id": "guid-of-image-1",
"url": "https://your-sitefinity-instance.com/images/image1.jpg",
"title": "Sample Image 1"
},
{
"id": "guid-of-image-2",
"url": "https://your-sitefinity-instance.com/images/image2.png",
"title": "Sample Image 2"
}
]
}
```
```
--------------------------------
### C# Sitefinity Dummy Module Implementation
Source: https://www.progress.com/documentation/sitefinity-cms/144/for-developers-install-a-module-with-the-fluent-api
This C# code demonstrates the structure of a dummy Sitefinity module, including its initialization, installation of module pages and toolbox items, and configuration settings. It utilizes Sitefinity's fluent API for module configuration and setup. Dependencies include Sitefinity core libraries.
```csharp
using DocumentationSamples.ModuleSamples;
using System;
using System.Collections.Specialized;
using Telerik.OpenAccess.Metadata;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.Data;
using Telerik.Sitefinity.Fluent.Definitions;
using Telerik.Sitefinity.Fluent.Modules;
using Telerik.Sitefinity.Localization;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Modules.GenericContent.Configuration;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Security.Configuration;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Web.UI.ContentUI;
using Telerik.Sitefinity.Web.UI.ContentUI.Config;
using Telerik.Sitefinity.Workflow.Model.Tracking;
[assembly: SitefinityModule(DummyModule.moduleName, typeof(DummyModule), "DummyModuleTitle", "DummyModuleDescription", StartupType.OnApplicationStart)]
namespace DocumentationSamples.ModuleSamples
{
public class DummyModule : ModuleBase
{
public override Guid LandingPageId
{
get { return homePageId; }
}
public override void Initialize(ModuleSettings settings)
{
base.Initialize(settings);
App.WorkWith().Module(Name)
.Initialize()
.Configuration()
.Localization();
}
public override void Install(SiteInitializer initializer)
{
initializer.Installer
.CreateModuleGroupPage(groupPageId, "Dummy")
.PlaceUnder(CommonNode.TypesOfContent)
.LocalizeUsing()
.SetTitleLocalized("PageGroupNodeTitle")
.SetUrlName("dummy")
.SetDescriptionLocalized("PageGroupNodeDescription")
.AddChildPage(DummyModule.homePageId, "DummyHome")
.LocalizeUsing()
.SetTitleLocalized("DummyTitle")
.SetHtmlTitleLocalized("DummyTitle")
.SetUrlName("dummyhome")
.SetDescriptionLocalized("DummyDescription")
.AddContentView(DummyModuleDefinitions.BackendDefinitionName, "DummyBackendView")
.Done()
.Done()
.PageToolbox()
.ContentSection()
.LoadOrAddWidget("DummyView")
.SetTitle("DummyViewTitle")
.SetDescription("DummyViewDescription")
.LocalizeUsing()
.SetCssClass("sfDummyViewIcn")
.Done()
.Done()
.Done()
.AddWorkflowType()
.SetTitle("DummyTitle")
.SetServiceUrl("~/Workflows/DummyWorkflow.xamlx")
.LocalizeUsing()
.Done();
}
public override void Upgrade(SiteInitializer initializer, Version upgradeFrom)
{
}
protected override ConfigSection GetModuleConfig()
{
return Config.Get();
}
public override Type[] Managers
{
get { return new Type[] { typeof(DummyModuleManager) }; }
}
internal static Guid groupPageId = new Guid("AB45CA65-B763-4C8A-84F1-442F701D3971");
internal static Guid homePageId = new Guid("AB45CA65-B763-4C8A-84F1-442F701D3972");
internal const string moduleName = "DummyModule";
}
internal class DummyModuleConfig : ContentModuleConfigBase
{
protected override void InitializeDefaultViews(ConfigElementDictionary contentViewControls)
{
contentViewControls.Add(DummyModuleDefinitions.BackendDefinitionName,
DummyModuleDefinitions.DefineDummyBackendContentView(contentViewControls));
}
protected override void InitializeDefaultProviders(ConfigElementDictionary providers)
{
providers.Add(new DataProviderSettings(providers)
{
Name = "OpenAccessDataProvider",
Description = "A provider that stores dummy module data in database using OpenAccess ORM.",
ProviderType = typeof(OpenAccessDummyModuleProvider),
Parameters = new NameValueCollection() { { "applicationName", "/Dummy" } }
});
}
protected override void OnPropertiesInitialized()
{
base.OnPropertiesInitialized();
InitializeDefaultPermissions();
}
protected virtual void InitializeDefaultPermissions()
{
var permission = new Permission(Permissions)
{
Name = "Dummy",
};
}
}
}
```
--------------------------------
### Install Roslyn Package via Package Manager Console
Source: https://www.progress.com/documentation/sitefinity-cms/144/sitefinity-cms-startup-process
This command installs the necessary Roslyn package for Sitefinity CMS. Ensure you install version 1.0.5 for optimal performance. This is typically used when manually managing project dependencies.
```csharp
Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
```
--------------------------------
### Get Live Event Occurrences by Date Range (C#)
Source: https://www.progress.com/documentation/sitefinity-cms/111/for-developers-manage-events-occurrences
Retrieves occurrences of all live events within a specified date range using the EventsManager. This method requires the start and end dates as input and returns a collection of EventOccurrence objects. It utilizes the System and Telerik.Sitefinity.Modules.Events namespaces.
```csharp
using System;
using System.Collections.Generic;
using Telerik.Sitefinity.Modules.Events;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.Events
{
public partial class EventsSnippets
{
public static IEnumerable GetEventsOccurrences()
{
var timeNow = DateTime.UtcNow;
var startRange = timeNow.AddHours(-2);
var manager = EventsManager.GetManager();
var occurrences = manager.GetEventsOccurrences(startRange, startRange.AddDays(20));
return occurrences;
}
}
}
```
--------------------------------
### Instantiate Sitefinity JavaScript SDK Object
Source: https://www.progress.com/documentation/sitefinity-cms/144/sitefinity-javascript-sdk
Demonstrates how to create an instance of the Sitefinity object, which serves as the entry point for SDK functionalities. It requires configuration options including the service URL and optional success/failure callback handlers.
```javascript
var sitefinityUrl = "http://mysite.com";
var options = {
serviceUrl: sitefinityUrl + "/api/default/",
handlers: {
failureCb: function () {
console.log("Global error occured");
},
successCb: function () {
console.log("Success executing request");
}
}
};
var sf = new Sitefinity(options);
```
--------------------------------
### Install Sitefinity CMS using NuGet Package Manager Console
Source: https://www.progress.com/documentation/sitefinity-cms/152/install-sitefinity-in-mvc-mode
Installs Sitefinity CMS modules into an ASP.NET Core project using the NuGet Package Manager Console in Visual Studio. Supports installing the full package or a light version, with options for specific versions.
```powershell
Install-Package Telerik.Sitefinity.All -IncludePrerelease
```
```powershell
Install-Package Progress.Sitefinity -IncludePrerelease
```
```powershell
Install-Package Telerik.Sitefinity.All -Version 14.4.8100.0 -IncludePrerelease
```
--------------------------------
### GET /api/default
Source: https://www.progress.com/documentation/sitefinity-cms/sf-docs/default-source/default-document-library/140/sitefinityodatapostmancollection_sfvrsn=8c9428cc_2
Retrieves the service root information. This endpoint can be used to check service availability and get basic service details.
```APIDOC
## GET /api/default
### Description
Retrieves the service root information. This endpoint can be used to check service availability and get basic service details.
### Method
GET
### Endpoint
/api/default
### Parameters
#### Header Parameters
- **Authorization** (string) - Required - The authorization token obtained from the login endpoint (e.g., "Bearer ").
### Response
#### Success Response (200)
- **value** (array) - An array of available service collections or endpoints.
#### Response Example
```json
{
"value": [
{
"name": "someCollection"
}
]
}
```
```
--------------------------------
### Sitefinity Precompiler Tool Usage Examples
Source: https://www.progress.com/documentation/sitefinity-cms/152/reference-command-line-arguments
Demonstrates how to use the Telerik.Sitefinity.Compiler.exe tool with different authentication methods. The first example uses username and password, while the second uses an authentication key, which is mandatory for Windows authentication.
```bash
Telerik.Sitefinity.Compiler.exe /url="http://localhost:8080" /appdir="D:\Projects\SitefinityWebApp" /username="sfadmin" /password="admin@2" /strategy="Frontend" /membershipprovider="Default"
```
```bash
Telerik.Sitefinity.Compiler.exe /url="http://localhost:8080" /appdir="D:\Projects\SitefinityWebApp" /authKey="8u3#u{9u~]k3M3Q" /strategy="Frontend"
```
--------------------------------
### Sitefinity CMS Precompiler Tool - Example 2 (Authentication Key)
Source: https://www.progress.com/documentation/sitefinity-cms/144/reference-command-line-arguments
This example shows how to use the Sitefinity CMS precompiler tool with an authentication key, which is required when Windows authentication is enabled. It specifies the URL, application directory, authentication key, and the precompilation strategy.
```bash
Telerik.Sitefinity.Compiler.exe /url="http://localhost:8080" /appdir="D:\Projects\SitefinityWebApp" /authKey="8u3#u{9u~]k3M3Q" /strategy="Frontend"
```
--------------------------------
### Install Telerik.Sitefinity.All Package (Package Manager Console)
Source: https://www.progress.com/documentation/sitefinity-cms/111/upgrade-from-sitefinity-cms-9
Installs the Telerik.Sitefinity.All metapackage with a specific version. This command is used to ensure the core Sitefinity CMS functionalities are installed or updated to the desired version. Execute this in the Visual Studio Package Manager Console.
```powershell
Install-Package Telerik.Sitefinity.All –Version 11.1.6800.0
```
--------------------------------
### Sitefinity CMS Precompiler Tool - Example 1 (Username/Password)
Source: https://www.progress.com/documentation/sitefinity-cms/144/reference-command-line-arguments
This example demonstrates how to use the Sitefinity CMS precompiler tool with username and password authentication. It specifies the URL, application directory, username, password, membership provider, and the precompilation strategy.
```bash
Telerik.Sitefinity.Compiler.exe /url="http://localhost:8080" /appdir="D:\Projects\SitefinityWebApp" /username="sfadmin" /password="admin@2" /strategy="Frontend" /membershipprovider="Default"
```
--------------------------------
### GET /api/default/{{taxaUrl}}
Source: https://www.progress.com/documentation/sitefinity-cms/sf-docs/default-source/default-document-library/140/sitefinityodatapostmancollection_sfvrsn=8c9428cc_2
Retrieves a list of taxa for a specific taxonomy. This is used to get all classification terms within a given category or tag set.
```APIDOC
## GET /api/default/{{taxaUrl}}
### Description
Retrieves a list of taxa for a specific taxonomy. This is used to get all classification terms within a given category or tag set.
### Method
GET
### Endpoint
/api/default/{{taxaUrl}} (Replace {{taxaUrl}} with the appropriate taxonomy URL, e.g., "categories", "tags")
### Response
#### Success Response (200)
- **Items** (array) - A list of taxon objects.
- **Id** (string) - The ID of the taxon.
- **Title** (string) - The title of the taxon.
- **UrlName** (string) - The URL-friendly name of the taxon.
- **TaxonomyId** (string) - The ID of the taxonomy it belongs to.
- **Name** (string) - The name of the taxon.
#### Response Example
```json
{
"Items": [
{
"Id": "some-guid-for-taxon-1",
"Title": "Technology",
"UrlName": "technology",
"TaxonomyId": "some-guid-for-categories",
"Name": "Technology"
},
{
"Id": "some-guid-for-taxon-2",
"Title": "Business",
"UrlName": "business",
"TaxonomyId": "some-guid-for-categories",
"Name": "Business"
}
]
}
```
```
--------------------------------
### Install Latest Sitefinity All Package (.NET)
Source: https://www.progress.com/documentation/sitefinity-cms/144/upgrade-from-sitefinity-cms-9
This command installs the latest stable version of the `Telerik.Sitefinity.All` NuGet package. It is essential for upgrading Sitefinity CMS to the newest patch build. To install a specific version, the '-Version' flag followed by the version number should be appended.
```csharp
Install-Package Telerik.Sitefinity.All
# Example for a specific version:
# Install-Package Telerik.Sitefinity.All -Version 15.2.8499
```
--------------------------------
### Instantiate Sitefinity JavaScript SDK Object
Source: https://www.progress.com/documentation/sitefinity-cms/152/sitefinity-javascript-sdk
Demonstrates how to create an instance of the Sitefinity object, which serves as the entry point for SDK functions. It requires configuration options including the service URL and optional handlers for request success and failure callbacks. These handlers can be used for logging or token management.
```javascript
var sitefinityUrl = "http://mysite.com";
var options = {
serviceUrl: sitefinityUrl + "/api/default/",
handlers: {
failureCb: function () {
console.log("Global error occured");
},
successCb: function () {
console.log("Success executing request");
}
}
}
var sf = new Sitefinity(options);
```
--------------------------------
### Example XLIFF with HTML Tags Stripped
Source: https://www.progress.com/documentation/sitefinity-cms/152/lionbridge-connector
An example of an XLIFF file content where HTML tags have been removed during the translation export process, as configured in the Lionbridge connector settings.
```xml
|
| This is just a test paragraph with a
| link
| , a
| strong
| tag and nothing else.
|
|
```
--------------------------------
### Sitefinity CMS Installer Class and Initialization (C#)
Source: https://www.progress.com/documentation/sitefinity-cms/144/custom-personalization-criteria-create-the-installer-class
This C# code defines the Installer class for Sitefinity CMS. It includes the PreApplicationStart method to subscribe to the Bootstrapper_Initialized event and the Bootstrapper_Initialized method to execute worker tasks upon application boot. It also contains helper methods for checking module installation, adding virtual paths, creating personalization criteria, registering evaluators, and creating personalization segments.
```csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Telerik.Microsoft.Practices.Unity;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Abstractions.VirtualPath.Configuration;
using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.Data;
using Telerik.Sitefinity.Localization;
using Telerik.Sitefinity.Modules.GenericContent.Web.UI;
using Telerik.Sitefinity.Modules.Pages;
using Telerik.Sitefinity.Pages.Model;
using Telerik.Sitefinity.Personalization;
using Telerik.Sitefinity.Personalization.Impl;
using Telerik.Sitefinity.Personalization.Impl.Configuration;
using Telerik.Sitefinity.Personalization.Impl.Model;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Workflow;
namespace SitefinityWebApp
{
public class Installer
{
public static void PreApplicationStart()
{
Bootstrapper.Initialized += (new EventHandler(Installer.Bootstrapper_Initialized));
}
private static void Bootstrapper_Initialized(object sender, ExecutedEventArgs e)
{
if (e.CommandName == "Bootstrapped")
{
SystemManager.RunWithElevatedPrivilegeDelegate worker = new SystemManager.RunWithElevatedPrivilegeDelegate(CreateSampleWorker);
SystemManager.RunWithElevatedPrivilege(worker);
}
}
private static void CreateSampleWorker(object[] parameters)
{
if (!IsPersonalizationModuleInstalled())
{
return;
}
AddVirtualPathToEmbeddedRes();
CreateCriteria();
RegisterCriteria();
CreateSegment();
CreateAndPersonalizePage();
}
private static bool IsPersonalizationModuleInstalled()
{
return SystemManager.ApplicationModules != null &&
SystemManager.ApplicationModules.ContainsKey(PersonalizationModule.ModuleName) &&
!(SystemManager.ApplicationModules[PersonalizationModule.ModuleName] is InactiveModule);
}
private static void AddVirtualPathToEmbeddedRes()
{
//Register the resource file
Res.RegisterResource();
var virtualPathConfig = Config.Get();
if (!virtualPathConfig.VirtualPaths.Contains(virtualPath + "*"))
{
var pathConfig = new VirtualPathElement(virtualPathConfig.VirtualPaths)
{
VirtualPath = Installer.virtualPath + "*",
ResolverName = "EmbeddedResourceResolver",
ResourceLocation = "DayOfWeekPersonalization"
};
virtualPathConfig.VirtualPaths.Add(pathConfig);
ConfigManager.GetManager().SaveSection(virtualPathConfig);
}
}
private static void CreateCriteria()
{
var personalizationConfig = Config.Get();
if (!personalizationConfig.Criteria.Contains(Res.Get().Day))
{
CriterionElement ageCriterion = new CriterionElement(personalizationConfig.Criteria)
{
Name = Res.Get().Day,
Title = Res.Get().Day,
ResourceClassId = typeof(CustomPersonalizationResources).Name,
CriterionEditorUrl = "DayOfWeekPersonalization.DayOfWeekEditor.ascx",
ConsoleCriterionEditorUrl = "DayOfWeekPersonalization.DayOfWeekEditor.ascx",
CriterionVirtualPathPrefix = Installer.virtualPath,
GroupName = "DayOfWeekPersonalization",
};
personalizationConfig.Criteria.Add(ageCriterion);
}
}
private static void RegisterCriteria()
{
ObjectFactory.Container.RegisterType(
typeof(ICriterionEvaluator),
typeof(DayOfWeekEvaluator),
Res.Get().Day,
new ContainerControlledLifetimeManager(),
new InjectionConstructor());
}
public static void CreateSegment()
{
var personalizationManager = PersonalizationManager.GetManager();
using (new ElevatedModeRegion(personalizationManager))
{
```
--------------------------------
### Sitefinity Insight .NET SDK: ABTestClient Constructors
Source: https://www.progress.com/documentation/sitefinity-cms/insight/other-clients
Initializes the ABTestClient for managing A/B tests. Requires an access token and datacenter key. Older versions may require a server address.
```.NET
public ABTestClient(IAccessToken token, string datacenterKey)
// For .NET SDK 3.1.8 or older:
public ABTestClient(IAccessToken token, string serverAddress, string datacenterKey)
```
--------------------------------
### Sitefinity CMS: Install Latest All Package
Source: https://www.progress.com/documentation/sitefinity-cms/152/upgrade-from-sitefinity-cms-9
Installs the latest available version of the `Telerik.Sitefinity.All` NuGet package. This command is crucial for upgrading the core Sitefinity CMS components to the most recent patch build. A specific version can be installed using the `-Version` flag.
```powershell
Install-Package Telerik.Sitefinity.All
# To install a specific version:
# Install-Package Telerik.Sitefinity.All -Version 15.2.8499
```
--------------------------------
### Sitefinity Insight .NET SDK: ConversionClient Constructor
Source: https://www.progress.com/documentation/sitefinity-cms/insight/other-clients
Initializes the ConversionClient for managing conversions and recommendations. Requires an access token and datacenter key. Older versions may require a server address.
```.NET
public ConversionClient(IAccessToken token, string datacenterKey)
// For .NET SDK 3.1.8 or older:
public ConversionClient(IAccessToken token, string serverAddress, string datacenterKey)
```
--------------------------------
### Configure Sitefinity Renderer appsettings.json
Source: https://www.progress.com/documentation/sitefinity-cms/152/sample--sitefinity-data-widget
This configuration snippet shows how to set up the connection details for the Sitefinity renderer to communicate with the Sitefinity CMS backend. It includes the CMS URL, web service path, and API key for secure communication.
```json
{
"Sitefinity": {
"Url": "https://yoursitefinitywebsiteurl",
"WebServicePath": "api/default",
"WebServiceApiKey": "mysecret"
}
}
```
--------------------------------
### Install Sitefinity CMS ASP.NET Core Renderer Packages (NuGet)
Source: https://www.progress.com/documentation/sitefinity-cms/install-sitefinity-in-
Instructions for installing Sitefinity CMS ASP.NET Core Renderer packages. This involves selecting 'nuget.org' as the package source and installing specific packages like Progress.Sitefinity.AspNetCore and Progress.Sitefinity.AspNetCore.Widgets into the 'Renderer' project.
```powershell
Install-Package Progress.Sitefinity.AspNetCore
Install-Package Progress.Sitefinity.AspNetCore.Widgets
```
--------------------------------
### Install Lionbridge Translation Connector NuGet Package
Source: https://www.progress.com/documentation/sitefinity-cms/152/lionbridge-connector
This snippet shows the command to install the Telerik.Sitefinity.Translations.Lionbridge NuGet package. Ensure you have the .NET CLI or NuGet Package Manager available.
```csharp
dotnet add package Telerik.Sitefinity.Translations.Lionbridge
```
--------------------------------
### Get Taxonomies using Sitefinity CMS API
Source: https://www.progress.com/documentation/sitefinity-cms/sf-docs/default-source/default-document-library/140/sitefinityodatapostmancollection_sfvrsn=8c9428cc_2
Retrieves a list of all taxonomies available in Sitefinity CMS. This GET request targets the '/api/default/taxonomies' endpoint and requires appropriate authorization headers.
```json
{
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "{{token_type}} {{token}}"
}
],
"url": {
"raw": "{{baseurl}}/api/default/taxonomies",
"host": [
"{{baseurl}}"
],
"path": [
"api",
"default",
"taxonomies"
]
}
}
```
--------------------------------
### Instantiate Sitefinity Libraries Manager (C#)
Source: https://www.progress.com/documentation/sitefinity-cms/111/for-developers-downloadable-files
This C# code snippet demonstrates how to instantiate the LibrariesManager using the 'SystemLibrariesProvider'. This is necessary for working with system libraries in Sitefinity CMS, such as the Downloadable Goods library. It includes basic structure for saving changes.
```csharp
using Telerik.Sitefinity.Modules.Libraries;
namespace SitefinityWebApp
{
public class WorkWithDownloadableFiles
{
public void DownloadFiles()
{
string providerName = "SystemLibrariesProvider";
LibrariesManager librariesManager = LibrariesManager.GetManager(providerName);
//custom logic goes here
librariesManager.SaveChanges();
}
}
}
```
--------------------------------
### List Installed npm Packages
Source: https://www.progress.com/documentation/sitefinity-cms/upgrade-next
This command displays all the packages installed in your project along with their current versions. It's useful for verifying the existing middleware versions in your Sitefinity Next.js renderer setup.
```bash
npm list
```
--------------------------------
### Sitefinity CMS: Assembly Registration for Custom Personalization
Source: https://www.progress.com/documentation/sitefinity-cms/144/custom-personalization-criteria-create-the-installer-class
This C# code shows how to register a custom installer class using the `PreApplicationStartMethod` attribute, ensuring it runs on application startup in Sitefinity CMS.
```csharp
[assembly: PreApplicationStartMethod(typeof(Installer), "PreApplicationStart")]
```
--------------------------------
### C# Sitefinity CMS Custom Module Implementation
Source: https://www.progress.com/documentation/sitefinity-cms/for-developers-install-a-module-with-the-fluent-api
This C# code defines a dummy Sitefinity CMS module, demonstrating how to scaffold custom module implementations. It includes initialization, installation, configuration, and manager definitions. This code is intended as a starting point for developers building their own modules.
```csharp
using DocumentationSamples.ModuleSamples;
using System;
using System.Collections.Specialized;
using Telerik.OpenAccess.Metadata;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Abstractions;
using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.Data;
using Telerik.Sitefinity.Fluent.Definitions;
using Telerik.Sitefinity.Fluent.Modules;
using Telerik.Sitefinity.Localization;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Modules.GenericContent.Configuration;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Security.Configuration;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Web.UI.ContentUI;
using Telerik.Sitefinity.Web.UI.ContentUI.Config;
using Telerik.Sitefinity.Workflow.Model.Tracking;
[assembly: SitefinityModule(DummyModule.moduleName, typeof(DummyModule), "DummyModuleTitle", "DummyModuleDescription", StartupType.OnApplicationStart)]
namespace DocumentationSamples.ModuleSamples
{
public class DummyModule : ModuleBase
{
public override Guid LandingPageId
{
get { return homePageId; }
}
public override void Initialize(ModuleSettings settings)
{
base.Initialize(settings);
App.WorkWith().Module(Name)
.Initialize()
.Configuration()
.Localization();
}
public override void Install(SiteInitializer initializer)
{
initializer.Installer
.CreateModuleGroupPage(groupPageId, "Dummy")
.PlaceUnder(CommonNode.TypesOfContent)
.LocalizeUsing()
.SetTitleLocalized("PageGroupNodeTitle")
.SetUrlName("dummy")
.SetDescriptionLocalized("PageGroupNodeDescription")
.AddChildPage(DummyModule.homePageId, "DummyHome")
.LocalizeUsing()
.SetTitleLocalized("DummyTitle")
.SetHtmlTitleLocalized("DummyTitle")
.SetUrlName("dummyhome")
.SetDescriptionLocalized("DummyDescription")
.AddContentView(DummyModuleDefinitions.BackendDefinitionName, "DummyBackendView")
.Done()
.Done()
.PageToolbox()
.ContentSection()
.LoadOrAddWidget("DummyView")
.SetTitle("DummyViewTitle")
.SetDescription("DummyViewDescription")
.LocalizeUsing()
.SetCssClass("sfDummyViewIcn")
.Done()
.Done()
.Done()
.AddWorkflowType()
.SetTitle("DummyTitle")
.SetServiceUrl("~/Workflows/DummyWorkflow.xamlx")
.LocalizeUsing()
.Done();
}
public override void Upgrade(SiteInitializer initializer, Version upgradeFrom)
{
}
protected override ConfigSection GetModuleConfig()
{
return Config.Get();
}
public override Type[] Managers
{
get { return new Type[] { typeof(DummyModuleManager) }; }
}
internal static Guid groupPageId = new Guid("AB45CA65-B763-4C8A-84F1-442F701D3971");
internal static Guid homePageId = new Guid("AB45CA65-B763-4C8A-84F1-442F701D3972");
internal const string moduleName = "DummyModule";
}
internal class DummyModuleConfig : ContentModuleConfigBase
{
protected override void InitializeDefaultViews(ConfigElementDictionary contentViewControls)
{
contentViewControls.Add(DummyModuleDefinitions.BackendDefinitionName,
DummyModuleDefinitions.DefineDummyBackendContentView(contentViewControls));
}
protected override void InitializeDefaultProviders(ConfigElementDictionary providers)
{
providers.Add(new DataProviderSettings(providers)
{
Name = "OpenAccessDataProvider",
Description = "A provider that stores dummy module data in database using OpenAccess ORM.",
ProviderType = typeof(OpenAccessDummyModuleProvider),
Parameters = new NameValueCollection() { { "applicationName", "/Dummy" } }
});
}
protected override void OnPropertiesInitialized()
{
base.OnPropertiesInitialized();
InitializeDefaultPermissions();
}
protected virtual void InitializeDefaultPermissions()
{
var permission = new Permission(Permissions)
{
Name = "Dummy",
};
}
}
internal static class DummyModuleDefinitions
{
public const string BackendDefinitionName = "DummyBackend";
public static ContentViewControlElement DefineDummyBackendContentView(ConfigElementDictionary contentViewControls)
{
var view = new ContentViewControlElement(contentViewControls)
{
Name = BackendDefinitionName,
Caption = "Dummy Backend View",
ViewType = typeof(ContentView),
MasterViewType = typeof(ContentViewMaster)
};
view.Views.Add(new CompositeViewElement(view.Views)
{
Name = "DummyMasterView",
ViewType = typeof(ContentViewMaster),
}},
);
var detailView = new DetailViewElement(view.Views)
{
Name = "DummyDetailView",
ViewType = typeof(DetailView)
};
var listView = new ListPagingViewElement(view.Views)
{
Name = "DummyListView",
ViewType = typeof(ListView),
};
view.Views.Add(listView);
view.Views.Add(detailView);
return view;
}
}
internal class DummyModuleItem : WorkflowItem
{
}
internal class DummyModuleView : ContentBlock
{
}
internal class DummyModuleManager : ManagerBase
{
}
internal class OpenAccessDummyModuleProvider : DataProviderBase
{
}
internal class DummyModuleResources : Resource {
}
}
```
--------------------------------
### Example XLIFF with HTML Tags Preserved
Source: https://www.progress.com/documentation/sitefinity-cms/152/lionbridge-connector
An example of an XLIFF file content where HTML tags are preserved (encoded) during the translation export process, when the 'Strip HTML tags' option is deselected.
```xml
|
| <p>This is just a test paragraph with a <a href="#">link</a>, a <strong>strong</strong> tag and nothing else.</p>
|
|
```
--------------------------------
### Measure Sitefinity CMS Startup Performance (web.config)
Source: https://www.progress.com/documentation/sitefinity-cms/111/sitefinity-cms-startup-process
This configuration setting in the `web.config` file enables detailed logging of the Sitefinity CMS startup process. It specifies a path for output files that show the duration of each startup phase and internal code blocks, aiding in performance diagnosis.
```xml
```
--------------------------------
### GET /api/default/{{entity}}/$count
Source: https://www.progress.com/documentation/sitefinity-cms/sf-docs/default-source/default-document-library/140/sitefinityodatapostmancollection_sfvrsn=8c9428cc_2
Returns the count of elements in a collection.
```APIDOC
## GET /api/default/{{entity}}/$count
### Description
Returns the total count of items in the specified collection.
### Method
GET
### Endpoint
`/api/default/{{entity}}/$count`
### Response
#### Success Response (200)
- A primitive number representing the count of items in the collection.
#### Response Example
```
150
```
```
--------------------------------
### Example .NET Core Project Structure for Sitefinity
Source: https://www.progress.com/documentation/sitefinity-cms/144/develop-widgets-with-asp
This snippet illustrates a recommended file and folder structure for an ASP.NET Core project integrated with Sitefinity CMS. It shows the organization of static assets, view components, models, views, and configuration files.
```text
| ├wwwroot
---|---
| ├───css
| ├───js
| ├───ViewComponents
| ├──────WidgetNameViewComponent.cs
| ├───Models
| ├──────WidgetName
| ├─────────WidgetModel.cs
| ├─────────IWIdgetModel.cs
| ├───ViewModels
| ├──────WidgetNameViewModel.cs
| ├───Entities
| ├──────WidgetNameEntity.cs
| ├───Views
| ├──────Shared
| ├─────────MyLayout.cshtml
| ├─────────Components
| ├────────────WidgetName
| ├───────────────Default.cshtml
| ├───appsettings.json
| └───Startup.cs
view raw NETCoreStruct.txt hosted with ❤ by GitHub
```
--------------------------------
### Sitefinity CMS: Define Page and Segment GUIDs (C#)
Source: https://www.progress.com/documentation/sitefinity-cms/152/custom-personalization-criteria-create-the-installer-class
Declares static GUID variables for a specific page and personalization segment within Sitefinity CMS. These identifiers are crucial for referencing and managing personalized content.
```csharp
private static readonly Guid segmentId = new Guid("2E68BB39-9D4E-4D8E-B53A-551B81D2FBA4");
private static readonly Guid pageId = new Guid("5B9B0941-3B78-4F23-842D-95820FDC5D0C");
```