"PublishLater" button Shape Overriding

Topics: Customizing Orchard, General
Dec 19, 2014 at 5:33 AM
I want to add an alternate for PublishLater button in admin menus. I'm not able to figure out the exact shape name to 'Descibe' the shape for the PublishLater button to add alternate. Any idea about how to find/know the shape name?

P.S I've tried "Parts_PublishLater" and "Parts_PublishLater_Edit" as these are used in placement.info and returned as shapes in Orchard.PublishLater module. It's not working!
Dec 19, 2014 at 10:31 AM
How exactly did you try? Because targeting the two shapes you mentioned should work.
Dec 19, 2014 at 1:58 PM
I tried this code.
public void Discover(ShapeTableBuilder builder)
               .OnDisplaying(displaying => 
But still, the PublishLater.cshtml under the EditorTemplates in Orchard.PublishLater module, executes and render the shape.
Dec 19, 2014 at 4:19 PM
So the displaying.ShapeMetadata.Alternates.Add("Content_MakeInvisible"); line gets called (try it with the debugger) and despite you having a Content.MakeInvisible.cshtml somewhere the latter doesn't get displayed?

Or are you trying to hide the Parts_PublishLater_Edit shape?
Dec 19, 2014 at 4:41 PM
Using a shape name like "Content_MakeInvisible" will reverse the two parts of that name, as described here (see the section on "Discovering alternates"). In summary:

The Display Type portion of a shape alternate gets special treatment when mapping it to a template file name. This is due to how the BasicShapeTemplateHarvester works, which is as follows:
  1. When Orchard is first started, it finds all of the Razor view files for every module and theme. Based on these filenames, a so called shape table is constructed.
  2. During the parsing of the filename (ignoring the file name extension), the convention is that the display type of the shape is the last portion of the filename after a dot. For example, of you have a file name called "Content-Animal.Summary", "Summary" will be recorded as the display type. Hyphens in a filename will be translated into a double underscore, and used as a so called breaking separator, which is used to further split the file name string into two. The harvester now has 3 components to build a shape name: The base name ("Content"), the display type ("Summary"), and the portion that comes after the base name ("Animal"). Let's refer to the latter as the "shape specializer".
  3. The 3 components are used to construct the shape name as follows: BaseName + "" + DisplayType + "_" + ShapeSpecializer.
Dec 19, 2014 at 4:45 PM
Edited Dec 19, 2014 at 4:45 PM
Actually after reading my own answer, it should work fine, since you're not using any "shape specializer".
As a test, you could try renaming "Content_MakeInvisible" to "Content__MakeInvisible" (also update your shape template name).
Dec 19, 2014 at 4:47 PM
Also, as per Zoltan's question, if you are trying to simply hide that shape, you should use Placement.info in your theme to hide that shape (which does even better than hiding - it prevents the shape from ever being created).

Like so:
<Place Parts_PublishLater_Edit="-" />
Dec 22, 2014 at 9:19 AM
Edited Dec 22, 2014 at 9:20 AM
@Piedone: Yes I want to hide Parts_PublishLater_Edit.

@sfmskywalker: tried everything but nothing is working :( and can't want to change placement.info file. I want to hide the PublishLater button when my certain condition returns true.
Dec 22, 2014 at 10:43 PM
By using shape tracing (without the AdminFilter test), I can see that, in fact, the shape type is "EditorTemplate", and the TemplateName is "Parts/PublishLater"

So, you can override it by using a PublishLater.cshtml in TheAdmin theme (or your current theme) /Views/EditorTemplates/Parts subfolder

If you want another name and add some logic before overriding, rename the file but let it in the same theme subfolder, and do this
    public class PublishLaterShape : IShapeTableProvider {
        public void Discover(ShapeTableBuilder builder) {
               .OnDisplaying(displaying => {
                   if (displaying.Shape.TemplateName == "Parts/PublishLater")
                       // Here, you can add your specific conditions
                       displaying.Shape.TemplateName = "Parts/Content.MakeInvisible";
Note that, here, there is no special character translations, and you can use any name, e.g only "Parts/MakeInvisible"

Marked as answer by TahirRauf on 12/22/2014 at 9:49 PM