Create content item by site users

Topics: Administration, Customizing Orchard, Writing modules
Jan 20, 2013 at 10:15 PM
Edited Jan 20, 2013 at 10:29 PM

I would like to user of my site can created content item from the open part of the site.

The easiest way that I know of - it orchard form. But how i can hide autoroute and containable part? How configure body part that hide insert media button?

Maybe there is another way to create content item?

Developer
Jan 22, 2013 at 9:37 AM

One way is to remove those parts from the content type.
Another way is to hide the rendered shapes by means of Placement.info

Feb 12, 2013 at 11:49 AM
Placement.info work fine
<Place Parts_Containable_Edit="-"
               Parts_Autoroute_Edit="-"
               Parts_Comments_Enable="-"
           />
Can i create alternates for EditorTemplates/Parts.Title.TitlePart.cshtml ?
Coordinator
Feb 12, 2013 at 5:30 PM
You can, if you take the original module as a dependency (and declare that in module.txt)
Feb 15, 2013 at 1:53 PM
I do this:
  1. Add to active module.txt Dependencies: Title
  2. Create alternates for edit content type: CurrentTheme/Views/Content.Edit-Profile.cshtml
  3. Add to this alternates
    foreach (var item in Model.Content.Items) {
        if (item.TemplateName == "Parts.Title.TitlePart") {
            item.TemplateName = "Parts.Title.TitlePart-Profile";
        }
    }
  1. Create CurrentTheme/EditorTemplates/Fields/Parts.Title.TitlePart-Profile.cshtml
But if i dont create Parts.Title.TitlePart-Profile.cshtml, that i get error.
How can i do if my CurrentTheme/EditorTemplates/Fields/Parts.Title.TitlePart-Profile.cshtml file does not exists, orchard take standart Parts.Title.TitlePart,cshtml
Developer
Feb 15, 2013 at 2:13 PM
I don't think editor shapes support alternates and I think this is a different subject from the original one.
However, if editor shapes did support alternates, you should not be setting the TemplateName to that alternate template, because you would be circumventing the alternates system, where it will look if a template exists for each registered alternate, and the first template it finds for the current alternate being checked will be applied.

A simple solution would be to verify yourself that the file exists. Because checking a file's existence is probably an expensive thing to do in terms of performance, you may want to cache that information.
Developer
Feb 15, 2013 at 2:15 PM
And I should add that your alternate template will never be picked since the current theme in the admin is TheAdmin, and not CurrentTheme.