### Run npm install and start Source: https://github.com/orchardcms/orchardcore/blob/main/src/OrchardCore.Themes/TheComingSoonTheme/Assets/TheComingSoonTheme/README.md After cloning the repository, install dependencies and start the development server for live preview and watching changes. ```bash npm install npm start ``` -------------------------------- ### Install via npm Source: https://github.com/orchardcms/orchardcore/blob/main/src/OrchardCore.Themes/TheComingSoonTheme/Assets/TheComingSoonTheme/README.md Install the Coming Soon theme using npm. This is a quick way to get started with the theme's assets. ```bash npm i startbootstrap-coming-soon ``` -------------------------------- ### Enable Auto Setup Feature in Startup Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/AutoSetup/README.md Add the Auto Setup feature to the service collection in the web project's `Startup` file. This is necessary to activate the Auto Setup functionality. ```csharp public void ConfigureServices(IServiceCollection services) { services .AddOrchardCms() .AddSetupFeatures("OrchardCore.AutoSetup"); } ``` -------------------------------- ### Retrieve Setup Recipe Parameters Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Scripting/README.md Access parameters provided during the setup process using `parameters('parameterName')`. Refer to the setup recipe parameters documentation for available options. ```json "Owner": "[js: parameters('AdminUserId')]" ``` -------------------------------- ### Host Appsettings.json Configuration Example in OrchardCore Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Setup/README.md An example JSON structure for host configuration, specifically showing how to set the 'AdminUrlPrefix' for OrchardCore. ```json { "OrchardCore_Admin" : { "AdminUrlPrefix" : "MyAdmin" } } ``` -------------------------------- ### Install Yarn and Build Assets Source: https://github.com/orchardcms/orchardcore/blob/main/AGENTS.md Installs Yarn and builds all frontend assets, including those managed by Gulp. Run from the repository root. ```bash corepack enable yarn yarn build ``` -------------------------------- ### Minimal Program.cs for Orchard Core CMS Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/decoupled-cms/README.md A minimal example of a Program.cs file configured for Orchard Core CMS, including service registration and middleware setup. ```csharp public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddOrchardCms(); var app = builder.Build(); app.UseStaticFiles(); app.UseOrchardCore(); app.Run(); } } ``` -------------------------------- ### Tenant Configuration Example in OrchardCore Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Setup/README.md An example JSON structure for providing tenant-specific configuration, including connection details and a custom configuration key. ```json { "ConnectionString": "...", "DatabaseProvider": "Sqlite", "TablePrefix": "Test", "CustomConfigurationKey": "Custom Configuration Value" } ``` -------------------------------- ### Install Orchard CMS Templates Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/getting-started/templates/README.md Installs the stable release of Orchard Core templates. Use this command to get started with Orchard Core development. ```CMD dotnet new install OrchardCore.ProjectTemplates::2.2.1 ``` -------------------------------- ### Install Agency Theme with npm Source: https://github.com/orchardcms/orchardcore/blob/main/src/OrchardCore.Themes/TheAgencyTheme/Assets/TheAgencyTheme/README.md Use npm to install the Agency theme. This is a quick way to get started with the theme's assets. ```bash npm i startbootstrap-agency ``` -------------------------------- ### Using Recipe Parameters in OrchardCore Setup Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Setup/README.md Demonstrates how to access setup screen values within a recipe using scripted values. Parameters like 'AdminUserId' can be retrieved using the `parameters()` function. ```json [js: parameters('AdminUserId')] ``` -------------------------------- ### Default Setup Configuration in OrchardCore Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Setup/README.md Default JSON configuration for the OrchardCore Setup module, specifying the default culture and a list of supported cultures for the setup screen. ```json { "OrchardCore_Setup": { "DefaultCulture": "", // When using "" the system OS culture will be used "SupportedCultures": [ "ar", "cs", "da", "de", "el", "en", "es", "fa", "fi", "fr", "he", "hr", "hu", "id", "it", "ja", "ko", "lt", "mk", "nl", "pl", "pt", "ru", "sk", "sl", "sr-cyrl-rs", "sr-latn-rs", "sv", "tr", "uk", "vi", "zh-CN", "zh-TW" ] // "" value (InvariantCulture) is not supported for these } } ``` -------------------------------- ### PO File Example Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Localize/javascript-localization.md Example of a standard Orchard Core PO file containing translation strings for different languages. ```po msgid "Save" msgstr "Enregistrer" msgid "Cancel" msgstr "Annuler" msgid "Delete" msgstr "Supprimer" ``` -------------------------------- ### Get Site Settings (Previous Method) Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/releases/2.0.0.md Shows the older, more verbose way to retrieve specific settings like LoginSettings by first getting all site settings and then casting them. ```csharp (await _siteService.GetSiteSettingsAsync()).As(); ``` -------------------------------- ### Install Clean Blog Theme via npm Source: https://github.com/orchardcms/orchardcore/blob/main/src/OrchardCore.Themes/TheBlogTheme/Assets/TheBlogTheme/README.md Use this command to install the Clean Blog theme using npm. Ensure you have Node.js and npm installed. ```bash npm i startbootstrap-clean-blog ``` -------------------------------- ### Install Orchard CMS Preview Templates Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/getting-started/templates/README.md Installs the latest `main` branch of Orchard Core templates using a preview NuGet source. This is useful for testing the newest features. ```CMD dotnet new install OrchardCore.ProjectTemplates::2.2.1-* --nuget-source https://nuget.cloudsmith.io/orchardcore/preview/v3/index.json ``` -------------------------------- ### Image Shortcode Usage Example Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Shortcodes/README.md Example demonstrating how to use the [image] shortcode to render an image from the site's media library with specified attributes. ```html [image alt="My lovely image"]my-image.jpg[/image] ``` -------------------------------- ### Recipe for URL Rewriting Rules Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/UrlRewriting/README.md Example recipe demonstrating the creation of redirect and rewrite rules. ```json { "steps": [ { "name": "UrlRewriting", "Rules": [ { "Source": "Redirect", "Name": "Redirect about-us to about", "Pattern": "^/about-us$", "SubstitutionPattern": "/about", "IsCaseInsensitive": true, "QueryStringPolicy": "Append", "RedirectType": "MovedPermanently" }, { "Source": "Rewrite", "Name": "Serve media URLs from img", "Pattern": "^/img/(.*)$", "SubstitutionPattern": "/media/$1", "IsCaseInsensitive": true, "QueryStringPolicy": "Drop", "SkipFurtherRules": true } ] } ] } ``` -------------------------------- ### Corepack and Yarn Installation Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/assets-manager/README.md Commands to enable Corepack and install project dependencies using Yarn. Administrator privileges may be required on Windows. ```cmd REM On Windows may require to run command shell with administrator privileges. corepack enable yarn ``` -------------------------------- ### Install Orchard Core Project Templates Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/create-cms-application/README.md Installs the latest stable release of the Orchard Core project templates. Use the `--nuget-source` option to point to a development branch. ```bash dotnet new install OrchardCore.ProjectTemplates::2.2.1-* ``` -------------------------------- ### Environment Variables for Auto Setup Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/AutoSetup/README.md Configure Auto Setup using environment variables, which are suitable for both server and local environments. Double underscores are used to denote nested configuration levels. ```plaintext "OrchardCore__OrchardCore_AutoSetup__AutoSetupPath": "" "OrchardCore__OrchardCore_AutoSetup__Tenants__0__ShellName": "Default" "OrchardCore__OrchardCore_AutoSetup__Tenants__0__SiteName": "AutoSetup Example" "OrchardCore__OrchardCore_AutoSetup__Tenants__0__SiteTimeZone": "Europe/Amsterdam" "OrchardCore__OrchardCore_AutoSetup__Tenants__0__AdminUsername": "admin" "OrchardCore__OrchardCore_AutoSetup__Tenants__0__AdminEmail": "info@orchardproject.net" "OrchardCore__OrchardCore_AutoSetup__Tenants__0__AdminPassword": "OrchardCoreRules1!" "OrchardCore__OrchardCore_AutoSetup__Tenants__0__DatabaseProvider": "Sqlite" "OrchardCore__OrchardCore_AutoSetup__Tenants__0__DatabaseConnectionString": "" "OrchardCore__OrchardCore_AutoSetup__Tenants__0__DatabaseTablePrefix": "" "OrchardCore__OrchardCore_AutoSetup__Tenants__0__RecipeName": "SaaS" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__ShellName": "AutoSetupTenant" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__SiteName": "AutoSetup Tenant" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__SiteTimeZone": "Europe/Amsterdam" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__AdminUsername": "tenantadmin" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__AdminEmail": "tenant@orchardproject.net" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__AdminPassword": "OrchardCoreRules1!" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__DatabaseProvider": "Sqlite" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__DatabaseConnectionString": "" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__DatabaseTablePrefix": "" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__RecipeName": "Agency" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__RequestUrlHost": "" "OrchardCore__OrchardCore_AutoSetup__Tenants__1__RequestUrlPrefix": "tenant" ``` -------------------------------- ### Resource Manifest Example for Minified Assets Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/assets-manager/README.md Example of defining a script in the resource manifest, specifying URLs for both minified and non-minified versions of the asset. ```csharp _manifest .DefineScript("my-app") .SetUrl("~/MyModule/Scripts/my-app.min.js", "~/MyModule/Scripts/my-app.js") .SetVersion("1.0.0"); ``` -------------------------------- ### Navbar Display Driver Example Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Admin/README.md Example of a C# display driver to add a 'Visit Site' link to the admin navbar. It specifies the view to use and its location. ```csharp public class VisitSiteNavbarDisplayDriver : DisplayDriver { public override IDisplayResult Display(Navbar model, BuildDisplayContext context) { return View("VisitSiteNavbarItem", model) .Location(OrchardCoreConstants.DisplayType.DetailAdmin, "Content:20"); } } ``` -------------------------------- ### Register Custom Deployment Step Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/releases/2.0.0.md Examples of how to register custom deployment steps using the new AddDeployment extensions. ```csharp services.AddDeployment(); ``` ```csharp services.AddDeployment(); ``` ```csharp services.AddDeploymentWithoutSource(); ``` -------------------------------- ### Module B Needs Bootstrap 5 Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/assets-manager/NPM_ALIASING_GUIDE.md Example of using the latest version of a package without an alias. ```json { "dependencies": { "bootstrap": "5.3.8" } } ``` -------------------------------- ### Tenant Pre-configuration Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Configuration/README.md Configure tenant setup values before creation by defining a tenant-specific section with 'State' set to 'Uninitialized'. ```json { "OrchardCore": { "MyTenant": { "State": "Uninitialized", "RequestUrlPrefix": "mytenant", "ConnectionString": "...", "DatabaseProvider": "SqlConnection" } } } ``` -------------------------------- ### Tenant Configuration in appsettings.json Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Configuration/README.md Example of tenant-specific configuration within an appsettings.json file. These settings override global configurations. ```json { "OrchardCore_Media": { // specific tenant configuration } } ``` -------------------------------- ### Configure Discoverable Stereotypes Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Apis.GraphQL/README.md Example of configuring GraphQL content options in a startup class to add specific stereotypes that should be discoverable by default. ```csharp services.Configure(options => { options.DiscoverableSterotypes.Add("ExampleStereotype"); }); ``` -------------------------------- ### GraphQL GET Request Example Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Apis.GraphQL/README.md Demonstrates how to send a GraphQL query using an HTTP GET request. The query is passed as a URL parameter. ```http https://localhost:44300/api/graphql?query={me{name}} ``` -------------------------------- ### Create Solution File and Add Projects Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/create-modular-application-mvc/README.md Creates a solution file and adds both the web application and module projects to it, facilitating management and opening in IDEs like Visual Studio. ```bash dotnet new sln -n OrchardCore.Mvc dotnet sln add OrchardCore.Mvc.Web\OrchardCore.Mvc.Web.csproj dotnet sln add OrchardCore.Mvc.HelloWorld\OrchardCore.Mvc.HelloWorld.csproj ``` -------------------------------- ### Permission Hierarchy Example Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/DataLocalization/README.md Illustrates the hierarchical structure of permissions within the Data Localization module, showing base permissions and culture-specific overrides. ```text ViewTranslations (Read-only access) ManageTranslations (Full edit access - implies ViewTranslations) ├── ManageTranslations_fr-FR (Edit French - implies ViewTranslations) ├── ManageTranslations_es-ES (Edit Spanish - implies ViewTranslations) └── ManageTranslations_{culture} (Dynamically generated per supported culture) ``` -------------------------------- ### Enable Database Shells Configuration in Startup.cs Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Shells/README.md Enable the Database Shells Configuration provider in your web host's Startup.cs file using an extension method on the Orchard Core Builder. ```csharp namespace OrchardCore.Cms.Web { public sealed class Startup { public void ConfigureServices(IServiceCollection services) { services.AddOrchardCms() .AddDatabaseShellsConfiguration(); } } } ``` -------------------------------- ### Example NPM Aliasing in package.json Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/assets-manager/NPM_ALIASING_GUIDE.md Demonstrates how to define aliases for different versions of a package like Vue in your package.json file. This allows installing and referencing specific versions under distinct names. ```json { "dependencies": { "vue": "3.5.13", // Latest version "vue-2.6.14": "npm:vue@2.6.14" // Alias for older version } } ``` -------------------------------- ### Configure Media Options in C# Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Media/README.md Use `services.PostConfigure` to customize the Media Library's `StaticFileOptions` in your application's startup configuration. This allows for detailed control over how static files are served. ```csharp services.PostConfigure(o => ...); ``` -------------------------------- ### PagerSlim Template Example Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Navigation/README.md Example Liquid template for customizing Pager_Next and Pager_Next shapes, which are morphed into Pager_Link. ```liquid {% shape_clear_alternates Model %} {% shape_type Model "Pager_Link" %} {% shape_add_classes Model "page-link" %} {{ Model | shape_render }} ``` -------------------------------- ### Install Playwright Browser Source: https://github.com/orchardcms/orchardcore/blob/main/test/OrchardCore.Tests.Functional/README.md Installs the Chromium browser for Playwright. This is typically done automatically on the first build, but can be run manually. ```bash dotnet build -c Release test/OrchardCore.Tests.Functional/OrchardCore.Tests.Functional.csproj dotnet exec test/OrchardCore.Tests.Functional/bin/Release/net10.0/Microsoft.Playwright.dll install chromium ``` -------------------------------- ### Enable Azure Shells Configuration in Startup.cs Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Shells/README.md Enable the Azure Shells Configuration provider in your web host's Startup.cs file using an extension method on the Orchard Core Builder. ```csharp namespace OrchardCore.Cms.Web { public sealed class Startup { public void ConfigureServices(IServiceCollection services) { services.AddOrchardCms() .AddAzureShellsConfiguration(); } } } ``` -------------------------------- ### Build and Run Orchard Core Docker Image Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/topics/docker/README.md These commands demonstrate how to build a Docker image from the Dockerfile and then run it as a container, exposing the application on port 80. Ensure you are in the directory containing the Dockerfile before running these commands. ```cmd REM Folder where the Dockerfile stands cd /orchardcore REM Build image from Dockerfile docker build -t oc . REM Creates a container, runs it and expose its service on port 80 docker run -p 80:80 oc ``` -------------------------------- ### Execute JavaScript Script Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Scripting/README.md Demonstrates how to get a scripting engine and evaluate a JavaScript expression to get the current date and time. ```csharp var scriptingManager = serviceProvider.GetService(); // Find the javascript engine by its prefix var engine = scriptingManager.GetScriptingEngine("js"); // Find all global methods in the system. Here you could add more methods to the scope as needed var globalMethods = _scriptingManager.GlobalMethodProviders.SelectMany(x => x.GetMethods()); // Create scope for the engine var scope = engine.CreateScope(globalMethods, serviceProvider, null, null); // Evaluate the given script var date = engine.Evaluate("js: new Date().toISOString()"); ``` -------------------------------- ### Implement Custom Navigation Provider (C#) Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Navigation/README.md Sample C# implementation of the INavigationProvider interface to extend the 'main' navigation menu with custom items. ```csharp public sealed class MainMenu : INavigationProvider { internal readonly IStringLocalizer S; public MainMenu(IStringLocalizer localizer) { S = localizer; } public ValueTask BuildNavigation(string name, NavigationBuilder builder) { //Only interact with the "main" navigation menu here. if (!String.Equals(name, "main", StringComparison.OrdinalIgnoreCase)) { return ValueTask.CompletedTask; } builder .Add(S["Notifications"], S["Notifications"], notifications => notifications .Action("Index", "Template", new { area = "CRT.Client.OrchardModules.CommunicationTemplates", groupId = "1" }) .LocalNav() ); return ValueTask.CompletedTask; } } ``` -------------------------------- ### Example of a Signed Media URL Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Media/README.md An example of a media URL with query string parameters including width, height, and a security token. ```html ``` -------------------------------- ### Initial Media Asset Migration Recipe Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Recipes/README.md This JSON recipe defines the initial migration step to add two media files. Ensure the SourcePath correctly points to the media file's location relative to the recipe file. ```json { "steps": [ { "name": "media", "Files": [ { "TargetPath": "about/1.jpg", "SourcePath": "../wwwroot/img/about/1.jpg" }, { "TargetPath": "about/2.jpg", "SourcePath": "../wwwroot/img/about/2.jpg" } ] } ] } ``` -------------------------------- ### Using Recipe Helper: file Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Recipes/README.md Loads content from an external file into a recipe. Often used for Liquid templates. ```json "Content": "[file:text('Snippets/homepage.liquid')]" ``` -------------------------------- ### Initialize Local NuGet Feed Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/topics/local-nuget-packages/README.md Use `nuget init` to copy the generated NuGet packages into a local directory that will serve as your custom NuGet feed. ```bash nuget init c:\OrchardCoreNuget \\{YourServer}\NuGetServer ``` -------------------------------- ### Install PO Extractor Tool Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Localize/README.md Install the OrchardCoreContrib.PoExtractor tool globally using the .NET CLI. This tool is used to generate .po files for localization. ```bash dotnet tool install --global OrchardCoreContrib.PoExtractor ``` -------------------------------- ### Build Orchard Core Solution Source: https://github.com/orchardcms/orchardcore/blob/main/AGENTS.md Build the entire Orchard Core solution from the repository root using the .NET CLI. Supports building with a Release configuration. ```bash # From repository root dotnet build OrchardCore.sln # Build with Release configuration dotnet build OrchardCore.sln -c Release ``` -------------------------------- ### Running Yarn Install Command Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/assets-manager/NPM_ALIASING_GUIDE.md Command to execute after updating package.json to install all defined dependencies and aliases. This step ensures that all package versions are correctly downloaded into node_modules. ```bash cd src yarn install ``` -------------------------------- ### Run with Launch Profile Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/AutoSetup/README.md Execute the web application project using a specific launch profile, such as 'web', which can be configured with environment variables in `launchSettings.json`. ```shell dotnet run --launch-profile web ``` -------------------------------- ### Set User Secrets for Auto Setup Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/AutoSetup/README.md Use `dotnet user-secrets` to set tenant-specific configurations for Auto Setup. This is useful for managing sensitive information during local development. ```shell cd src/OrchardCore.Cms.Web dotnet user-secrets init dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:ShellName" "Default" dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:SiteName" "AutoSetup Example" dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:SiteTimeZone" "Europe/Amsterdam" dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:AdminUsername" "admin" dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:AdminEmail" "info@orchardproject.net" dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:AdminPassword" "OrchardCoreRules1!" dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:RecipeName" "SaaS" dotnet user-secrets set "OrchardCore:OrchardCore_AutoSetup:Tenants:0:DatabaseProvider" "Sqlite" ``` -------------------------------- ### Build Orchard Core CMS Web Project Source: https://github.com/orchardcms/orchardcore/blob/main/AGENTS.md Navigate to the web project directory and run the application using the .NET CLI. Alternatively, build with a specific configuration and target framework. ```bash # Navigate to the web project cd src/OrchardCore.Cms.Web # Run the application dotnet run # Or build with specific configuration dotnet build -c Debug -f net10.0 ``` -------------------------------- ### Get Asset URL using Media Profile Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Media/README.md Use the AssetProfileUrlAsync helper to get an asset URL based on a predefined Media Profile. This requires asynchronous execution. ```cshtml @await Orchard.AssetProfileUrlAsync(Model.Paths[0], "medium") ``` -------------------------------- ### Basic Example: Single Input File Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/gulp-pipeline/README.md Transpiles a single LESS stylesheet to CSS, adding vendor prefixes, source maps, a header, normalizing line endings, and minifying. ```json [ { "inputs": [ "Assets/Styles.less" ], "output": "Styles/Styles.css" } ] ``` -------------------------------- ### GraphQL GET Request Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Apis.GraphQL/README.md Execute GraphQL queries using an HTTP GET request. The query is passed as a query string parameter. Variables and operation names can also be specified. ```APIDOC ## GET /api/graphql ### Description Executes a GraphQL query specified in the 'query' query string parameter. ### Method GET ### Endpoint `/api/graphql?query={your_graphql_query}` ### Query Parameters - **query** (string) - Required - The GraphQL query string. - **variables** (string) - Optional - A JSON-encoded string of variables for the query. - **operationName** (string) - Optional - The name of the operation to execute if the query contains multiple operations. ### Response #### Success Response (200) - **data** (object) - The result of the GraphQL query. - **errors** (array) - An array of errors, if any occurred during query execution. ``` -------------------------------- ### Configure Lockout Options in Startup.cs Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/lockout-configuration/README.md Inject IConfiguration into the Startup class to read settings from configuration sources. ```csharp public IConfiguration Configuration { get; } ``` ```csharp public sealed Startup(IConfiguration configuration) { Configuration = configuration; } ``` -------------------------------- ### Auto-Setup Tenant Configuration Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/AutoSetup/README.md Configure tenant-specific settings for auto-setup within the appsettings.json file. This includes details like ShellName, SiteName, Admin credentials, database provider, and recipe name. Use this to define multiple tenants with varying configurations. ```json { "OrchardCore": { "OrchardCore_AutoSetup": { "AutoSetupPath": "", "Tenants": [ { "ShellName": "Default", "SiteName": "AutoSetup Example", "SiteTimeZone": "Europe/Amsterdam", "AdminUsername": "admin", "AdminEmail": "info@orchardproject.net", "AdminPassword": "OrchardCoreRules1!", "DatabaseProvider": "Sqlite", "DatabaseConnectionString": "", "DatabaseTablePrefix": "", "RecipeName": "SaaS" }, { "ShellName": "AutoSetupTenant", "SiteName": "AutoSetup Tenant", "SiteTimeZone": "Europe/Amsterdam", "AdminUsername": "tenantadmin", "AdminEmail": "tenant@orchardproject.net", "AdminPassword": "OrchardCoreRules1!", "DatabaseProvider": "Sqlite", "DatabaseConnectionString": "", "DatabaseTablePrefix": "tenant", "RecipeName": "Agency", "RequestUrlHost": "", "RequestUrlPrefix": "tenant", "FeatureProfile": "my-profile" } ] } } } ``` -------------------------------- ### Starting Lucene Query for Blog Posts Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/query-content-items-based-on-taxonomy/README.md This is a basic Lucene query to fetch 10 BlogPosts without any filters. It serves as a starting point for more complex queries and is used when no taxonomy filters are provided. ```json { "size": 10, "query": { "term": { "Content.ContentItem.ContentType.keyword" : "BlogPost" } } } ``` -------------------------------- ### Enable Redis Lock and Auto Setup Features Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/AutoSetup/README.md Enable the Redis Lock and AutoSetup features in your application's startup configuration. This ensures that the distributed locking mechanism is active for the auto setup process. ```csharp public void ConfigureServices(IServiceCollection services) { services .AddOrchardCms() .AddSetupFeatures("OrchardCore.Redis.Lock", "OrchardCore.AutoSetup"); } ``` -------------------------------- ### Start Orchard Core in Background (PowerShell) Source: https://github.com/orchardcms/orchardcore/blob/main/AGENTS.md This script determines a port, starts the Orchard Core application in the background, and saves its process ID. It also includes commands to stop the process and reset application data. ```powershell $port = if (Test-Path .orchardcore-port) { Get-Content .orchardcore-port } else { $p = Get-Random -Min 5000 -Max 6000; $p | Out-File .orchardcore-port -NoNewline; $p } $proc = Start-Process dotnet -ArgumentList "run","-f","net10.0","--no-build","--urls","http://localhost:$port" -WorkingDirectory "src/OrchardCore.Cms.Web" -PassThru -NoNewWindow $proc.Id | Out-File .orchardcore-pid -NoNewline # URL: http://localhost:$port # Test credentials: admin / admin@test.com / Password1! # Stop when done Stop-Process -Id (Get-Content .orchardcore-pid) -Force; Remove-Item .orchardcore-pid # Reset state: Remove-Item -Recurse -Force src/OrchardCore.Cms.Web/App_Data ``` -------------------------------- ### Get Content Item Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Contents/README.md Retrieves a specific content item by its ID. ```APIDOC ## GET /api/content/{contentItemId} ### Description Retrieves a specific content item using its unique identifier. ### Method GET ### Endpoint /api/content/{contentItemId} ### Parameters #### Path Parameters - **contentItemId** (string) - Required - The ID of the Content Item to be retrieved. ``` -------------------------------- ### Get User ID Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Liquid/README.md Retrieves the unique identifier of the currently authenticated user. ```liquid {{ User | user_id }} ``` -------------------------------- ### Create Index Profile Recipe Step Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Indexing/README.md Defines a step in a recipe to create or update an index profile. This example specifies details for indexing content items. ```json { "steps":[ { "name":"CreateOrUpdateIndexProfile", "indexes": [ { "Id": "The id", "Name": "UniqueName", "IndexName": "blogposts", "ProviderName": "ProviderName", "Type": "Content", "Properties": { "ContentIndexMetadata": { "IndexLatest": false, "IndexedContentTypes": ["BlogPosts"], "Culture": "any" } } } ] } ] } ``` -------------------------------- ### Get User Email Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Liquid/README.md Retrieves the email address of the currently authenticated user. ```liquid {{ User | user_email }} ``` -------------------------------- ### Navigation Arguments Generation Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/topics/source-generators/README.md Example of generating arguments for Navigation using the `[GenerateArguments]` attribute. ```csharp [GenerateArguments] internal sealed partial class NavigationArguments { public string MenuName { get; set; } public string RouteUrl { get; set; } } ``` -------------------------------- ### Configure Password Settings from appsettings.json Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/password-configuration/README.md This approach reads password configuration from an external JSON file, offering more flexibility. Ensure your `Startup` class has an `IConfiguration` property and a constructor to initialize it. ```csharp public IConfiguration Configuration { get; } ``` ```csharp public sealed Startup(IConfiguration configuration) { Configuration = configuration; } ``` ```csharp services.Configure(options => { Configuration.GetSection("IdentityOptions").Bind(options); }); ``` ```json { "IdentityOptions": { "Password": { "RequireDigit": false, "RequireLowercase": true, "RequireUppercase": true, "RequireNonAlphanumeric": false, "RequiredUniqueChars": 3, "RequiredLength": 6 } } } ``` -------------------------------- ### PagerSlim Arguments Generation Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/topics/source-generators/README.md Example of generating arguments for a PagerSlim shape using the `[GenerateArguments]` attribute. ```csharp [GenerateArguments] public partial class PagerSlim { public int PageSize { get; set; } public string Before { get; set; } public string After { get; set; } } ``` -------------------------------- ### Multiple Vue Versions Configuration Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/assets-manager/NPM_ALIASING_GUIDE.md Example showing how to manage multiple versions of Vue using NPM aliasing in package.json and then configuring Assets.json to copy specific distribution files for each version to different output directories. ```json { "dependencies": { "vue": "3.5.13", "vue-2.6.14": "npm:vue@2.6.14" } } ``` ```json [ { "action": "copy", "name": "vue2", "source": "node_modules/vue-2.6.14/dist/*.js", "dest": "wwwroot/Vendor/vue-2.6.14/" }, { "action": "copy", "name": "vue3", "source": "node_modules/vue/dist/*.js", "dest": "wwwroot/Scripts/" } ] ``` -------------------------------- ### Run the Orchard Core Web Application Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/guides/create-modular-application-mvc/README.md Starts the Orchard Core web application from its project directory. Includes a note for development branch template users regarding `dotnet restore`. ```bash dotnet run --project .\OrchardCore.Mvc.Web\OrchardCore.Mvc.Web.csproj ``` -------------------------------- ### Complete Program.cs for Orchard Core CMS (.NET 6+) Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/getting-started/README.md This is an example of a complete `Program.cs` file for an Orchard Core CMS application using .NET 6 and later, including service registration and request pipeline configuration. ```csharp var builder = WebApplication.CreateBuilder(args); builder.Services.AddOrchardCms(); var app = builder.Build(); if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseStaticFiles(); app.UseOrchardCore(); app.Run(); ``` -------------------------------- ### Queries Recipe Step Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Elasticsearch/README.md An example of creating an Elasticsearch query within a Queries recipe step. ```APIDOC ## Queries Recipe Step ### Description Here is an example for creating a Elasticsearch query from a Queries recipe step: ### Request Body ```json { "steps":[ { "Source": "Elasticsearch", "Name": "RecentBlogPosts", "Index": "Search", "Template": "...", // json encoded query template "ReturnContentItems": true } ] } ``` ``` -------------------------------- ### Implement a Simple Activity Display Driver Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Workflows/README.md Example of a display driver for a custom activity. It maps properties between the activity and its view model for editing and updating. ```csharp public class NotifyTaskDisplayDriver : ActivityDisplayDriver { protected override void EditActivity(NotifyTask activity, NotifyTaskViewModel model) { model.NotificationType = activity.NotificationType; model.Message = activity.Message.Expression; } protected override void UpdateActivity(NotifyTaskViewModel model, NotifyTask activity) { activity.NotificationType = model.NotificationType; activity.Message = new WorkflowExpression(model.Message); } } ``` -------------------------------- ### Basic GraphQL Query Source: https://github.com/orchardcms/orchardcore/blob/main/src/docs/reference/modules/Apis.GraphQL.Abstractions/README.md An example of a simple GraphQL query to retrieve the 'displayText' from a 'blog' type. ```APIDOC ## Basic GraphQL Query ### Description This is a basic example of a GraphQL query that retrieves the `displayText` field from the `blog` type. ### Query Structure ```json { blog { displayText } } ``` ### Type `blog` ```