Orchard cms将data-mediapicker-uploadpath添加到自定义类型

时间:2012-09-05 15:39:44

标签: tinymce orchardcms

我在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"];

in ../../ 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。我还是迷路了!

0 个答案:

没有答案