1

我在 orchard cms 中创建了一个自定义类型,它有两列布局

它有 2 个标题文本文件和 2 个内容 HTML 风格文件

继承人迁移:

public class MigrationTwoColumnPageType : DataMigrationImpl
{
    public int Create()
    {
        // Define the project type 
        ContentDefinitionManager.AlterTypeDefinition("TwoColumnPage", cfg => cfg
            .WithSetting("Stereotype", "Content")
            .CommomPart()
            .AutoroutePart()
            .WithPart("TitlePart")
            .WithPart("MenuPart")
            .WithPart("TagsPart")
            .WithPart("PublishLaterPart")
            .WithPart("TwoColumnPage")
            .Creatable()
            .Draftable());

        return 1;

    }

    public int UpdateFrom1()
    {
        // Define project part - having a part with the same name will create fields in the project type
        ContentDefinitionManager.AlterPartDefinition("TwoColumnPage", builder => builder
           .TextField("Column1Title", Flavour.Large)
           .TextField("Column1Text", Flavour.Html)
           .TextField("Column2Title", Flavour.Large)
           .TextField("Column2Text", Flavour.Html)
           .Attachable());

        return 2;
    }   
}

注意:TextField 是一种自定义扩展方法,可以让事情变得不那么冗长

当我尝试使用媒体选择器将图像上传到这些内容字段之一时,我收到一个未找到文件夹的错误,-我已将其追溯到未设置请求查询字符串上的媒体路径

// media directory to save uploaded files into
    var mediaPath = Request["uploadpath"];

在 ../../Orchard.MediaPicker/Views/admin/Tab_Url.cshtml

有没有办法使用归档设置进行设置?

似乎对于我创建的任何页面都可以正常工作,但是自定义类型....如何设置此值?

更新

这是页面的 xml 元数据...

<!--Exported from Orchard-->
<Orchard>
  <Recipe>
    <Name>Generated by Orchard.ImportExport</Name>
    <Author>admin</Author>
  </Recipe>
  <Metadata>
    <Types>
      <Page ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" TypeIndexing.Included="true" DisplayName="Page">
        <NavigationPart />
        <CommonPart DateEditorSettings.ShowDateEditor="true" />
        <PublishLaterPart />
        <TitlePart />
        <AutoroutePart AutorouteSettings.AllowCustomPattern="true" AutorouteSettings.AutomaticAdjustmentOnEdit="false" AutorouteSettings.PatternDefinitions="[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-page'}]" AutorouteSettings.DefaultPatternIndex="0" />
        <BodyPart />
        <TagsPart />
        <LocalizationPart />
      </Page>
    </Types>
    <Parts>
      <NavigationPart ContentPartSettings.Attachable="True" />
      <CommonPart ContentPartSettings.Attachable="True" />
      <PublishLaterPart ContentPartSettings.Attachable="True" />
      <TitlePart ContentPartSettings.Attachable="True" />
      <AutoroutePart ContentPartSettings.Attachable="True" />
      <BodyPart ContentPartSettings.Attachable="True" BodyPartSettings.FlavorDefault="html" />
      <TagsPart ContentPartSettings.Attachable="True" />
      <LocalizationPart />
    </Parts>
  </Metadata>
</Orchard>

这是我的自定义类型的 XML 元数据,使用 TestFiledSetting 而不是 BodyPartSetting

<!--Exported from Orchard-->
<Orchard>
  <Recipe>
    <Name>Generated by Orchard.ImportExport</Name>
    <Author>admin</Author>
  </Recipe>
  <Metadata>
    <Types>
      <TwoColumnPage Stereotype="Content" OwnerEditorSettings.ShowOwnerEditor="false" ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" DisplayName="Two Column Page">
        <CommonPart />
        <AutoroutePart AutorouteSettings.PatternDefinitions="[{Name:'/Title', Pattern: '/{Content.Slug}', Description: 'my-page'}]" />
        <TitlePart />
        <MenuPart />
        <TagsPart />
        <PublishLaterPart />
        <TwoColumnPage />
      </TwoColumnPage>
    </Types>
    <Parts>
      <CommonPart ContentPartSettings.Attachable="True" />
      <AutoroutePart ContentPartSettings.Attachable="True" />
      <TitlePart ContentPartSettings.Attachable="True" />
      <MenuPart ContentPartSettings.Attachable="True" />
      <TagsPart ContentPartSettings.Attachable="True" />
      <PublishLaterPart ContentPartSettings.Attachable="True" />
      <TwoColumnPage ContentPartSettings.Attachable="True">
        <Column1Title.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Large" TextFieldSettings.Hint="" />
        <Column1Text.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Html" TextFieldSettings.Hint="" />
        <Column2Title.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Large" TextFieldSettings.Hint="" />
        <Column2Text.TextField TextFieldSettings.Required="True" TextFieldSettings.Flavor="Html" TextFieldSettings.Hint="" />
      </TwoColumnPage>
    </Parts>
  </Metadata>
</Orchard>

两者都没有提到 data-mediapicker-uploadpath 。我还是迷路了!

4

0 回答 0