Orchard cms adding data-mediapicker-uploadpath to a custom type - tinymce

I have created a custom type in orchard cms, that has a two column lay out
It has 2 header text fileds and 2 content HTML flavour fileds
Heres the migration :
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;
}
}
NOTE: TextField is a custom extension method to make things less verbose
When I try and use the media picker to up load an image into one of these content fields I get a folder not found error, - I have traced this back to the media path on the Request querystring not being set
// media directory to save uploaded files into
var mediaPath = Request["uploadpath"];
in ../../Orchard.MediaPicker/Views/admin/Tab_Url.cshtml
Is there some way to set this using filed settings ?
Seems to work fine for any pages I create, but custom types .... how do I set this value ?
UPDATE
Heres the xml meta data for a page...
<!--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>
Here's the XML meta for my custom type, using TestFiledSetting instead of 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>
No mention of data-mediapicker-uploadpath in either. I'm still lost!

Related

SharePoint PnP - Adding fields to default view

I’m using the SharePoint PnP templates to deploy a list instance to SharePoint 2016. Is it possible to make the field “TheName” part of the default view or a particular view using an attribute?
Below I’ve set the “TheName” field attributes Viewable="true" ShowInDisplayForm="true" ShowInViewForms="true" but that has not resulted in “TheName” being part of the default view. Below is the xml for the list instance:
<pnp:ListInstance Title="Application" Description="" EnableAttachments="true" DocumentTemplate="" TemplateType="100" Url="Lists/Application" MinorVersionLimit="0" MaxVersionLimit="0" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-de22-43b2-a848-c05709900100" ContentTypesEnabled="true" EnableFolderCreation="true">
<pnp:ContentTypeBindings>
<pnp:ContentTypeBinding ContentTypeID="0x0109413FF39DA2049E08C8B9564402E3562" Default="true" />
</pnp:ContentTypeBindings>
<pnp:Fields>
<pnp:Field Type="Text" DisplayName="TheName" StaticName="TheName" Name="TheName" Default="true" ID="{db2beb10-5325-434d-a559-691e340a4fea}" Viewable="true" ShowInDisplayForm="true" ShowInViewForms="true" />
</pnp:Fields>
</pnp:Views>
</pnp:ListInstance>
I can explicitly create/set the default view to include “TheName” but then I end up having to list all the fields that are part of the list including the ones which come from a site content type. This can become a hassle to maintain. The below list instance xml displays “TheName” as part of the default view:
<pnp:ListInstance Title="Application" Description="" EnableAttachments="true" DocumentTemplate="" TemplateType="100" Url="Lists/Application" MinorVersionLimit="0" MaxVersionLimit="0" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-de22-43b2-a848-c05709900100" ContentTypesEnabled="true" EnableFolderCreation="true">
<pnp:ContentTypeBindings>
<pnp:ContentTypeBinding ContentTypeID="0x0109413FF39DA2049E08C8B9564402E3562" Default="true" />
</pnp:ContentTypeBindings>
<pnp:Fields>
<pnp:Field Type="Text" DisplayName="TheName" StaticName="TheName" Name="TheName" Default="true" ID="{db2beb10-5325-434d-a559-691e340a4fea}" Viewable="true" ShowInDisplayForm="true" ShowInViewForms="true" />
</pnp:Fields>
<pnp:Views>
<View DisplayName="All Items">
<ViewFields>
<FieldRef Name="TheName" />
<FieldRef Name="Title" />
<FieldRef Name="ApplicationId" />
<FieldRef Name="Case" />
</ViewFields>
</View>
</pnp:Views>
</pnp:ListInstance>

Cannot filter by string from remote url

Created a WCF Data Service to pull data from Oracle database and when debugging in VS I can use the ?$filter syntax to filter returned sets.
However, using the remote url I cannot.
Point to note: I can filter by integers and dates, however I cannot filter by strings.
Also, I cannot filter by any string field in code. The filter is ignored.
Sample item below:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="http://localhost:61905/CampaignerSVC.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<title type="text">Contacts</title>
<id>http://localhost:61905/CampaignerSVC.svc/Contacts</id>
<updated>2015-04-29T15:06:48Z</updated>
<link rel="self" title="Contacts" href="Contacts" />
<entry>
<id>http://localhost:61905/CampaignerSVC.svc/Contacts(23517014)</id>
<title type="text"></title>
<updated>2015-04-29T15:06:48Z</updated>
<author>
<name />
</author>
<link rel="edit" title="ContactList" href="Contacts(23517014)" />
<category term="Campaigner_DAL_WCF.ContactList" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:LicenseNumber m:type="Edm.Int32">23517014</d:LicenseNumber>
<d:ClientCode>2000</d:ClientCode>
<d:ClientName>Doodler</d:ClientName>
<d:ClientMnemonic>DD</d:ClientMnemonic>
<d:LastName>Kerr</d:LastName>
<d:FirstName>Rover</d:FirstName>
<d:MiddleName>Frank</d:MiddleName>
<d:Title>Mr.</d:Title>
<d:PreferredFirstName>Rover</d:PreferredFirstName>
<d:PreferredMiddleName>Frank</d:PreferredMiddleName>
<d:CompanyName m:null="true" />
<d:JobTitle m:null="true" />
<d:Gender>M</d:Gender>
<d:DateOfBirth m:type="Edm.DateTime">1947-04-27T00:00:00</d:DateOfBirth>
<d:PrimaryChapterCode m:type="Edm.Int16">400</d:PrimaryChapterCode>
<d:AlternateChapterCode m:type="Edm.Int16" m:null="true" />
<d:MainAddrStreetNo>121</d:MainAddrStreetNo>
<d:MainAddrLine1>So Crescent</d:MainAddrLine1>
<d:MainAddrLine2 m:null="true" />
<d:MainAddrLine3 m:null="true" />
<d:MainAddrCity>MAICK</d:MainAddrCity>
<d:MainAddrProvCode>ON</d:MainAddrProvCode>
<d:MainAddrProv>Ontario</d:MainAddrProv>
<d:MainAddrPostalCode>KB7</d:MainAddrPostalCode>
<d:MainAddrCountryCode>CA</d:MainAddrCountryCode>
<d:MainAddrCountry>Canada</d:MainAddrCountry>
<d:MainPhoneNum>610-000-0703</d:MainPhoneNum>
<d:MainPhoneExt m:null="true" />
<d:MainFaxNum m:null="true" />
<d:MainEmailAddr>someone#rogers.com</d:MainEmailAddr>
<d:CellPhoneNum m:null="true" />
<d:ChangeType>D</d:ChangeType>
<d:EventTimeStamp m:type="Edm.DateTime">2015-04-29T02:40:02</d:EventTimeStamp>
<d:PrivacyIndicator>N</d:PrivacyIndicator>
</m:properties>
</content>
</entry>
</feed>
You can filter by string also by using the string in quotes like below-
'string'
Ok, so the issue was that I had created a class to store the results from the entity model.
Although I had a DataKey value specified, the problem was that the field I specified was not unique, therefore the filters were being ignore (or only the first matching record was filtered).
What I had to do was decorate the class with a composite DataKey.

iTextSharp SetField for fields with same name on different pages

I used acroFields.GetTranslatedFieldName() to get the next fieldnames from the pdf:
topmostSubform[0].Page1[0].CheckBox2A[0]
topmostSubform[0].Page1[0].CheckBox2A[1]
topmostSubform[0].Page2[0].CheckBox2A[0]
topmostSubform[0].Page2[0].CheckBox2A[1]
topmostSubform[0].Page3[0].CheckBox2A[0]
topmostSubform[0].Page3[0].CheckBox2A[1]
I use the next line of code to fill CheckBox2A[0] on the second page.
fields.SetField("topmostSubform[0].Page2[0].CheckBox2A[0]", "1")
Instead of CheckBox2A[0] on the second page, CheckBox2A[0] on the first page gets checked.
iTextSharp (and also iText for Java, tested here) does not correctly associate the reference derived from the XFA template structure
topmostSubform[0].Page2[0].CheckBox2A[0]
with the matching entry in the one XFA dataset:
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" >
<xfa:data >
<topmostSubform >
<!-- vvv the incorrect match by iText -->
<CheckBox2A >0</CheckBox2A >
<!-- ^^^ the incorrect match by iText -->
<CheckBox2A >0</CheckBox2A >
<CheckBox2B >0</CheckBox2B >
<CheckBox2B >0</CheckBox2B >
<Voorletters />
<Achternaam />
<CheckBox2C >0</CheckBox2C >
<CheckBox2C >0</CheckBox2C >
<DatumDag />
<DatumMaand />
<DatumJaar />
<TextField1 />
<HuisNrTekst5 />
<HuisNrNummer5 />
<Straat />
<PostcodeNr1c />
<PostcodeAlpha1c />
<Plaats />
<HuisNrTekst5 />
<HuisNrNummer5 />
<TextField1 />
<PostcodeNr1c />
<PostcodeAlpha1c />
<Plaats />
<TextField1 />
<CheckBox2D >0</CheckBox2D >
<CheckBox2D >0</CheckBox2D >
<IBANREKC_1 />
<IBANREKB_1 />
<IBANREKA_1 />
<IBAN_1 />
<BurgerserviceNr />
<Voorletters />
<Achternaam />
<CheckBox2E >0</CheckBox2E >
<CheckBox2E >0</CheckBox2E >
<HuisNrTekst5 />
<HuisNrNummer5 />
<Straat />
<PostcodeNr1c />
<PostcodeAlpha1c />
<Plaats />
<DatumDag />
<DatumMaand />
<DatumJaar />
<IBANREKC_2 />
<IBANREKB_2 />
<IBANREKA_2 />
<IBAN_2 />
<Telefoon />
<!-- vvv the correct match -->
<CheckBox2A >0</CheckBox2A >
<!-- ^^^ the correct match -->
<CheckBox2A >0</CheckBox2A >
<CheckBox2B >0</CheckBox2B >
<CheckBox2B >0</CheckBox2B >
<IBANREKC_1 />
<IBANREKB_1 />
<IBANREKA_1 />
<IBAN_1 />
<CheckBox2C >0</CheckBox2C >
<CheckBox2C >0</CheckBox2C >
<TextField1 />
<TextField1 />
<CheckBox2D >0</CheckBox2D >
<CheckBox2D >0</CheckBox2D >
<Telefoon />
<CheckBox2E >0</CheckBox2E >
<CheckBox2E >0</CheckBox2E >
<CheckBox2F >0</CheckBox2F >
<CheckBox2F >0</CheckBox2F >
<TextField1 />
<TextField1 />
<CheckBox2G >0</CheckBox2G >
<CheckBox2G >0</CheckBox2G >
<CheckBox3B >0</CheckBox3B >
<CheckBox3B >0</CheckBox3B >
<CheckBox3B >0</CheckBox3B >
<IBAN_1E_01 />
<IBAN_1D_01 />
<IBAN_1C_01 />
<IBAN_1A_01 />
<IBAN_1B_01 />
<IBANREKC_1 />
<IBANREKB_1 />
<IBANREKA_1 />
<IBAN_1 />
<IBAN_1E_02 />
<IBAN_1D_02 />
<IBAN_1C_02 />
<IBAN_1B_02 />
<IBAN_1A_02 />
<CheckBox3D >0</CheckBox3D >
<CheckBox3D >0</CheckBox3D >
<CheckBox3D >0</CheckBox3D >
<CheckBox3A >0</CheckBox3A >
<CheckBox3A >0</CheckBox3A >
<CheckBox3A >0</CheckBox3A >
<CheckBox2A >0</CheckBox2A >
<CheckBox2A >0</CheckBox2A >
<CheckBox3B >0</CheckBox3B >
<CheckBox3B >0</CheckBox3B >
<CheckBox3B >0</CheckBox3B >
<DatumDag />
<DatumMaand />
<DatumJaar />
<TextField1 />
<DatumDag />
<DatumMaand />
<DatumJaar />
<TextField1 />
<Telefoon />
</topmostSubform >
</xfa:data >
</xfa:datasets >
Thus, the wrong dataset element is changed. I'm afraid this has to be looked into by iText development, I have no fix at hand.
You might be in luck, though: The form in your document actually is a hybrid with both an AcroForm and an XFA representation. During your fields.SetField call iText attempts to set the value in both representations, and indeed, in the AcroForm representation it sets the correct one.
Thus, if the result PDF is not required to carry that XFA structure anymore, you can simply drop the XFA structure:
using (var pdfReader = new PdfReader(file))
using (FileStream output = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write))
using (PdfStamper pdfStamper = new PdfStamper(pdfReader, output))
{
AcroFields fields = pdfStamper.AcroFields;
fields.SetField("topmostSubform[0].Page2[0].CheckBox2A[0]", "1");
fields.RemoveXfa();
}
Doing that you get the tick on page 2:

Do I have to use XML parsing or any other way of saving the server response

I am getting the following response from server:
<?xml version="1.0" encoding="UTF-8"?>
<tracks type="array">
<track>
<id type="integer">13082503</id>
<created-at type="datetime">2011-04-05T05:48:05Z</created-at>
<user-id type="integer">2796383</user-id>
<duration type="integer">6715</duration>
<commentable type="boolean">true</commentable>
<state>finished</state>
<sharing>public</sharing>
<tag-list />
<permalink>myfirstsong-tutorial1-6</permalink>
<description nil="true" />
<streamable type="boolean">true</streamable>
<downloadable type="boolean">false</downloadable>
<genre nil="true" />
<release nil="true" />
<purchase-url nil="true" />
<label-id nil="true" />
<label-name nil="true" />
<isrc nil="true" />
<video-url nil="true" />
<track-type nil="true" />
<key-signature nil="true" />
<bpm nil="true" />
<title>MyFirstSong-Tutorial1</title>
<release-year nil="true" />
<release-month nil="true" />
<release-day nil="true" />
<original-format>m4a</original-format>
<license>all-rights-reserved</license>
<uri>http://api.soundcloud.com/tracks/13082503</uri>
<permalink-url>http://soundcloud.com/sleuth007/myfirstsong-tutorial1-6</permalink-url>
<artwork-url nil="true" />
<waveform-url>http://w1.sndcdn.com/8MqNbtkeyhNZ_m.png</waveform-url>
<user>
<id type="integer">2796383</id>
<permalink>sleuth007</permalink>
<username>sleuth007</username>
<uri>http://api.soundcloud.com/users/2796383</uri>
<permalink-url>http://soundcloud.com/sleuth007</permalink-url>
<avatar-url>http://a1.sndcdn.com/images/default_avatar_large.png?5fb6c47</avatar-url>
</user>
<stream-url>http://api.soundcloud.com/tracks/13082503/stream</stream-url>
<downloads-remaining type="integer">100</downloads-remaining>
<secret-token>s-5vz60</secret-token>
<secret-uri>http://api.soundcloud.com/tracks/13082503?secret_token=s-5vz60</secret-uri>
<user-playback-count type="integer">1</user-playback-count>
<user-favorite type="boolean">false</user-favorite>
<playback-count type="integer">0</playback-count>
<download-count type="integer">0</download-count>
<favoritings-count type="integer">0</favoritings-count>
<comment-count type="integer">0</comment-count>
<created-with>
<id type="integer">61</id>
<name>Cocoa API Wrapper Test</name>
<uri>http://api.soundcloud.com/apps/61</uri>
<permalink-url>http://soundcloud.com/apps/cocoa-api-wrapper-test</permalink-url>
</created-with>
<attachments-uri>http://api.soundcloud.com/tracks/13082503/attachments</attachments-uri>
</track>
</tracks>
Do I have to do XML parsing for this or is there any other way to save this as array
You will have to use NSXMLParser for parsing the xml file. "type=array" is XML attribute and not an array.

How do I return an Entity Framework Entity from a WCF Data Service Webget?

I'm trying to return a simple object (that was created in an EDMX with EF 4) through a WebGet operation in my WCF Data Service. I'm able to see the object, but the property that is an object is not populated (int this Case DisplaySize is empty, even though I've set it. I'm planning on making a database call to populate this from a non-EF generated table because we haven't migrated all the data to the new schema yet. (please infer the object types from this)
[WebGet]
[SingleResultAttribute]
public Display GetDisplay(int displayId)
{
Display foundDisplay = new Display();
foundDisplay.DisplaySize = new DisplaySize() { Id = 1, Width = 1024, Height = 768, Dimensions = "1024 X 768" };
foundDisplay.Id = displayId;
return foundDisplay;
}
the url call I'm using: http://localhost:1354/services/EDMDataService.svc/GetDisplay?displayId=1
The xml from the call is:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="http://localhost:1354/services/EDMDataService.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<id>http://localhost:1354/services/EDMDataService.svc/Displays(1)</id>
<title type="text"></title>
<updated>2010-11-12T19:34:29Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Display" href="Displays(1)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/DisplaySize" type="application/atom+xml;type=entry" title="DisplaySize" href="Displays(1)/DisplaySize" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Address" type="application/atom+xml;type=entry" title="Address" href="Displays(1)/Address" />
<category term="DataModels.Display" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:DisplaySizeID m:type="Edm.Int32">0</d:DisplaySizeID>
<d:DisplayTypeID m:type="Edm.Int32">0</d:DisplayTypeID>
<d:TimeZoneID m:type="Edm.Int32" m:null="true" />
<d:Facing m:null="true" />
<d:PanelNumber m:type="Edm.Int32" m:null="true" />
<d:DisplayTemplateTypeID m:type="Edm.Int32">1</d:DisplayTemplateTypeID>
<d:DisplayGUID m:null="true" />
<d:RegistrationKey m:null="true" />
<d:FirmwareVersion m:null="true" />
<d:Id m:type="Edm.Int32">1</d:Id>
<d:Base m:type="DataModels.Base">
<d:Title>test</d:Title>
<d:Summary>Description would go here</d:Summary>
<d:DataCenterSiteID m:type="Edm.Int32">0</d:DataCenterSiteID>
</d:Base>
</m:properties>
</content>
</entry>
Just add &$expand=DisplaySize to your URL, and the response will contain the expanded entity as well.