How to add Image/file uploader in custom form : Orchard CMS - orchardcms

I have create a module in Orchard cms, In which I have created the custom form say for 'staff list'.
For the Custom form of staff list I have created the different field like Name, age, phone , gender etc..in a table 'staffDetails' through dataManuputaion class. For Add and edit the staff Detail I follow the same procedure and created admin UI through ContentPartDriver class.
And I have also created the custom mvc view page for client section where I show all the staff details in grid. All the process is working fine. Now I want to add a image upload in admin add/edit section in of staff detail. And same uploaded image I want show in client section in grid respect to each staff detail.Can anyone tell me how to add image and get it url to show in client section. How the whole process will work. Let me know if any more detail required.

Add MediaLibraryPickerField after create table in Migration class.
SchemaBuilder.CreateTable("StaffRecord", table => table
.ContentPartRecord()
.Column<string>("Name", col => col.WithLength(100))
.Column<string>("SmallPhoto", col => col.WithLength(500))
.Column<bool>("IsActive", col => col.WithDefault(true))
);
ContentDefinitionManager.AlterPartDefinition("StaffPart", part => part
.WithField("SmallPhoto", field => field
.OfType("MediaLibraryPickerField")
.WithDisplayName("Small Photo")));

The media library fields that you can use in the admin won't work on the front-end. You'll have to build your own equivalent part or field.

Related

Populate data back to form in Kentico

Here's what I'd like to do but not sure how to. I have a form that's like a typical doctor/school form, where the form has 2 sections: [1] Section 1 at the top is for user (with standard fields like First Name, Last Name etc.), and [2] Section 2 at the bottom is for Admin/Office use only (with fields like Reviewed by, Approved/Not Approved etc.)
what I was able to do is to process Section 1 where I got ALL users' submission and display all their data on a webpage using a RepeaterWithCustomQuery. That's pretty basic. But in order to do what described above, I guess that I'll need to pull the submitted data and populate them back to Section 1 of the form (maybe as readonly data at this time) and then the Office/Admin staff can fill in Section 2.
I hope I made sense and hope that someone can point me to the right direction. I only use Portal Engine, no access to file system or backend.
I think I understand your issue you want to have some sort of an editor for biz form data. Similar to what you have in the admin. And the problem is that you don't have access to backend. :( Such thing is available for custom table data (there is web part), but not for biz form data. There is no ready to use web part. Here is old topic on that https://devnet.kentico.com/questions/how-to-edit-the-information-of-a-record-using-the-bizform-layout.
you want to have something like the admin page for editing form records:
/CMSModules/BizForms/Tools/BizForm_Edit_EditRecord.aspx?formID=7&formRecordID=1
but customized :(. I'd say without back end access the only options I see:
Create a new role "Biz Form Editor" (or use existing) that has rights only to edit biz
form data. So all your people who do "validation" part must have a
Kentico account with role "Biz Form Editor".
Add link above to your repeater with appropriate record id.
P.S. There are special code names for alternative forms (https://docs.kentico.com/k8/configuring-kentico/creating-alternative-forms/code-names-of-automatically-used-alternative-forms). If you create an alternative form with special name update the system will automatically load it when you edit the record.
Not sure that I understood correctly your question. But what you need is to use alternative forms. So the idea is that one form is for "registration" and the 2nd one for "validation".
So in your registration form you show only firstName, lastName etc and you don't show "validation" fields. In the validation form you show firstName, lastname etc as label and show textboxes for validation fields.

Liferay: Dynamically populate 'select' structure field

I am building a liferay theme, which has two columns side by side. The right column is where the web contents will be displayed.
My implementation aims to build a menu (left column) that gets the titles from the web content titles and builds hierarchy (parent, child) based on a 'select' structure field that I added to each web content.
So far I was able to build this system using
Liferay.Service('/journalarticle/get-articles'...)
and some javascript coding.
Now the 'select' fields i use in my structure have predefined hard coded options.
How can i populate dynamically this option list so that whoever is managing content will automatically have all titles from all web contents available to choose a 'parent' from? So far a developer has to update this option list each time there is a new web content added.
#chadct : AFAIK Liferay not provide this default functionality, this is not good practice to populate dynamically value in structure field. But you wanted to achieve that functionality, then there are 4 solution :
Add one text field in structure which contains articleId of your parent web content.
You can add related article for that web content and write some sort of code to get article which consider as a parent of that web content.
Create Select DOM options form template which hold the list of article according to groupId and render on web content view mode, then you can select parent content from there and update content expando with articleId of parent webcontent. Remember this contains AJAX post request. and only show that control who is admin or loggedin user or depends on Role. Refer AJAX post calling
Hook edit_structure.jsp and add your logic here as you want.
Note : last one is worst but also a solution, Remember you need to modify your current solution.

Dynamic columns in liferay-ui:search-container?

I have tried the liferay-ui:search-container to fetch and display the database table records on UI in a table/grid format. By using the liferay-ui:search-container I am getting the output as shown below,
I am fetching the USER_ table records in the above screen shot.
Problem:
I wanted to make the grid columns dynamic like, I wanted to enable an option for end user to remove the unwanted columns and add the wanted columns in the respective grid/table.
EX:
In the above screen shot the the following columns are showing in a grid.
First Name, Last Name, Screen Name, Job Title, Organization, User Groups
Now If user wants to remove Job Title and wants to add Greetings and Mail Address columns on UI with click events with out touching/ modifying the code.
How can I implement this feature?
Note:
I need to implement this feature for custom models.
Queries:
1) Is there any api/methods to implement/enable this feature?
2) If not how can I do implement the steps? Any suggestions or steps to achieve this task?
This can be achieved by adding a configuration page to your portlet.
You can develop portlet configuration page which can have required options to be configured and save as portlet preferences.
Later on while displaying the search container you can retrieve the portlet preferences and display only those columns which were selected in the configuration form.
Here is a link on how to develop the portlet configuration using portlet preferences: Implementing Configurable Portlet Preferences

modx revo adding fields in user module

I am new to modx revo and trying to add extra fields in user creation from backend. Which file should i check out for customization. I added the custom field in backend with this code on modx.panel.user.js file.
{
id: 'modx-user-companyname'
,name: 'company_name'
,fieldLabel: _('company_name')
,xtype: 'textfield'
,anchor: '100%'
,maxLength: 255
}
I created custom column named company_name in database table modx_users but I don't know how to save it on database. Any ideas?
Editing the core code of modx is considered a bad idea.
Really you have two options if you want to add extra properties to users...
Firstly you could take advantage of modUser extended field which allows you to store extra properties for the user and are stored as JSON. This is available in the default ui in the manager.
See Understanding MODX Extended User Fields and JSON
Secondly, you could extend modUser. This would give you full control over the user model and could then add additional related entities. From then, you might be able to alter the user form in the manager with form customisation or write a plugin to alter view.
See Extending modUser

Orchard cms,create a list of selected content on admin menu

I am trying to make a list of a specific content type by making a query and show the list on the admin menu. I created a projection to associate the query and added to the admin menu. But when I click on the menu created, it navigates to the edit mode of the projection definition but I was expecting a list. Can anybody help how to create a list of selected content type which can access from admin menu?
Regards
George
There are examples of code adding custom lists of content items in Vandelay.Industries. The repo for Vandelay can be found here.
The way it works is that it actually just creates admin menu items that point to the existing Admin controller in the Content feature that displays lists of content items. That controller is already equipped for filtering items by content type.
item.Action("List", "Admin",
new RouteValueDictionary {
{"area", "Contents"},
{"model.Id", definition.Name}
})
You can find the controller in question in the Orchard repo, if you want to write your own version for your own specific purposes (but again, you don't need to if you just want to display items filtered by type in the admin in a way consistent with the rest of the dashboard).
The relevant code is this:
_contentManager.Query(versionOptions, model.TypeName);

Resources