You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否批量将指定内容类型的所有内容项添加至2sxc列表?

Bulk-Add All Items from a Specific Content Type to a 2sxc List (No Manual Clicking!)

Great question—manually adding dozens or hundreds of content items to a 2sxc List is a total time-suck, so let’s break down the most efficient ways to handle this in bulk:

1. Use the 2sxc Admin UI (Quick & No-Code)

If you’re working within the same DNN/2sxc instance, the built-in bulk selection tool is your first go-to:

  • Open your 2sxc List module’s management interface, then navigate to the Items tab
  • Look for the Add Existing button (usually in the top toolbar)
  • In the content picker modal, use the dropdown filter to select your target content type
  • Batch-select items: Use Ctrl+Click (Windows) or Cmd+Click (Mac) to pick multiple items, or check the top checkbox to select all items in the filtered list
  • Hit Add Selected—done! No more tedious one-by-one clicks.

2. Use a Razor Script (For Large Datasets or Automation)

If you have hundreds/thousands of items (and the UI starts lagging), a quick Razor script will handle this in seconds. Here’s a template you can adapt:

// Replace with your source content type name
var sourceContentType = "YourSourceContentType";
// Replace with your List's content type name
var listContentType = "YourListContentType";
// Replace with the field name in your List that references the source items
var referenceFieldName = "RelatedSourceItem";

// Get all source items
var sourceItems = App.Data[sourceContentType].ToList();

// Loop through and add each to the List (as a reference, not a copy)
foreach (var item in sourceItems)
{
    // Create a new List item linked to the source content
    App.Data.Create(listContentType, new {
        // Map required fields - adjust these to match your List's fields
        Title = item.Title,
        [referenceFieldName] = item.EntityId
    });
}

// Optional: Confirm completion
<p>Successfully added @sourceItems.Count items to the List!</p>

How to use this:

  • Create a new 2sxc App or use an existing one, then add a new Razor view
  • Paste the code, replace the placeholder values with your actual content type/field names
  • View the page once to run the script (it will execute immediately)
  • Important: Delete or disable the view after running to avoid accidentally duplicating items

Critical Notes Before You Start

  • Backup your data first: Bulk operations can go wrong—take a DNN content backup before proceeding
  • If your List uses copies of content (not references), adjust the script to copy field values instead of linking EntityIds
  • For extremely large datasets (10k+ items), add a batch loop with small delays to avoid timeouts

内容的提问来源于stack exchange,提问作者Joe Craig

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 09:14:27