New Content Type Creation In Liferay - liferay

I am trying to create a new content type in liferay. Just as the existing content types it already has (blogs,discussions or posts) , we would like to have a new content type holder(example : photo) in our application which can have the same features as the existing ones.
Firstly is it possible to customize liferay to achieve this ?
If yes, any pointers to the same will be of great help !!
Thanks.

Extends the portal-ext.properties:
journal.article.types=announcements,blogs,general,news,press-release,test

Related

Orchard Content Parts that Don't Store Information in the Database

I'm trying to create a content part in Orchard that will perform a request to a web server and display the results of the request. The problem I'm running into is that my part requires no user input and thus I have left the part and part record classes empty. I have a Migrations.cs file that adds a description to the part and makes it attachable as well as creates a content item with the part attached to it. When I go to create a new instance of my content type it tries writing to the database and fails. How do you create a content part in orchard that doesn't try to save to the database? Thank you.
The actual error I receive is:
null id in Orchard.ContentManagement.Records.ContentTypeRecord
I'm pretty sure you don't need to create new table since there are many parts which don't have any in Orchard. Try to remove MyCustomPartRecord.cs and change MyCustomPart.cs
public class MyCustomPart : ContentPart<MyCustomPartRecord>
to
public class MyCustomPart : ContentPart
Then just add driver and view and you should be good without extra tables ... In theory :D
The answer to my problem is even when your part ins't actually saving anything in the database you still need to include a table for the part so it can store the id. I just added the following to my Migrations.cs file and it fixed the problem.
SchemaBuilder.CreateTable("MyCustomPartRecord",
table => table
.ContentPartRecord()
);

Orchard CMS: add image to custom Item

Hi once again :) My next question about Orchard CMS looks trivial but..
I have my custom NewsModule with NewsItem type which consists of TitlePart, BodyPrt, and my custom NewsPart. NewsPart is based on NewsPartRecord.
Now I have to extend my NewsItem document type with Image. So far I found that there are ImagePart and MediaLibraryPickerField.
ImagePart stores width and heihgt of image, so I think it is something for internal use.
The next one is MediaLibraryPickerField. After googling for a while, I found that I can extend my NewsPart using WithField() method.
But! First question here: when I'm configuring Page type with Admin UI, I can add field to the type. But using Migrations I can't add field to NewsItem, only to NewsPart.
The second question here. MediaLibraryPicker allows me to select any type of file from library, image, text, zip or any other. And this is not what I actually need.
So, what are the best practices in Orchard to extend Items with icons?
thanks.
You can add fields to NewsItem, it just requires a different type of definition. It confused me too as it's not as intuitive as you'd like it to be.
To add parts you are using AlterTypeDefinition.
this.ContentDefinitionManager.AlterTypeDefinition(
"NewsItem",
cfg => cfg.WithPart("NewsPart"));
But to add fields you have to also use AlterPartDefinition and specify the NewsItem not the NewsPart.
this.ContentDefinitionManager.AlterPartDefinition(
"NewsItem",
builder =>
builder.WithField(
"NewsImages",
fieldBuilder =>
fieldBuilder.OfType("MediaLibraryPickerField")
.WithDisplayName("News Images")
// Allow multiple images
.WithSetting("MediaLibraryPickerFieldSettings.Multiple", "true"))
Considering second question, MediaLibraryPickerField has option to display only selected types/parts.
.WithSetting(MediaLibraryPickerFieldSettings.DisplayedContentTypes="Document,Video")
If you need new media type you have to create new ContentType with Stereotype "Media", it also needs "MediaPart" and part that defines metadata for that type. You can look at how Document or Video is defined for sample code.

adding config items in Orchard Module

I was wondering on how to add configurable items in a Orchard module (analogous to appsettings key-value in a webapp). Could anyone me point to the right source/url in the web ?
Orchard has a rich settings infrastructure. It is not as simple to implement as the appsettings.config, but is a lot more powerful. You can add settings to the site (shown in the main 'settings' section of the dashboard) or for a specific content type, content part, field or even a part when it is attached to a specific content type. You can define custom settings parts so that your settings can be managed by end users through the dashboard.
For an example of both site settings and content type settings you can look at the Orchard.Comments module. There are also some good blog posts on creating your own custom settings in your module:
http://www.szmyd.com.pl/blog/how-to-add-settings-to-your-content-parts-and-items
http://www.szmyd.com.pl/blog/using-custom-settings-in-orchard-part-2-content-type-settings
I think the proper way to achieve this is to create a Record and leverage orchards database migration functionality. Orchard does the heavy lifting and you end up with a strongly typed object and repository! I believe the examples on the Orchard site use this technique for the custom Content Types but you can create them without just create your model
public class Item {
public string Key {get;set;}
public string Value {get;set;}
}
Then in the migration define your table with a table name equal to your model name
SchemaBuilder.CreateTable("Item",
table => table
.Column<string>("Key",column => column.PrimaryKey().Identity())
.Column<string>("Value", column => column.NotNull()
.WithLength(30)
Then you can inject a repository where yu need it
public class MyDriver : ContentFieldDriver<MyPart>
{
public MyDriver(IRepository<Item> itemRepository) {... }
Thats it!

Umbraco add custom Document Type

Is it possible to add a custom control to the Document Type? Suppose i couldn't create a multiselect or just a simple textfield control. How could i create a custom one and use that from the Document Type page in Umbraco?
If this is possible, then what steps need to be taken? Because i can add all sorts of config information in the Document Type controls that currently exist in there. Like, when i add a textfield i can gvie it a name, an alias and a validation message (and it has some others options).
Do i have to build the custom Document Type control in a specific way? And how is it saved to the database? How does Umbraco handle that?
Any information on this matter is more than welcome!
Since adding custom document types is native to Umbraco, and judging by the description in your question, I'm going to assume that you are talking about adding custom data types with user controls.
If so, check some of the following links on the subject, it's actually fairly simple:
Creating custom datatypes using the umbraco usercontrol wrapper (I personally used this one)
Custom DataTypes in Umbraco
Creating a custom datatype using the usercontrol wrapper (Video tutorial)

How to get ContentItems with specific part in Orchard?

I'm writing a module for Orchard and I need to know how to query the Orchard DB for ContentItems with a specific part. I want to do this in my PartDriver so I can return a SelectList with all the ContentItems present. I understand most of what I need to do except for the part where I query Orchard for the ContentItems.
Any one? Thanks in advance!
Inject IContentManager and Query<YourPart, YourPartRecord>

Resources