Multi-Feature placement.info

Topics: Customizing Orchard, General, Writing modules
Mar 9, 2012 at 4:51 PM

So I'm trying to do some integration with Vandelay.Classy for my menu module.  I want to override the editor for it and I'm seeing some weird alternate/placement.info behavior.  I can make everything work, but I can't make it work when I try to do it the *right* way.  Here's what I'm doing, which doesn't work.

module.txt

 

SchoolPointe.Menus:
	Name: Menus
    Description: Flexible menu replacement
	Category: Navigation
	Dependencies: SchoolPointe.RelatedContent, Orchard.Autoroute, Common, Orchard.Search, Navigation, Orchard.Widgets, Orchard.jQuery
SchoolPointe.Menus.Classy:
	Name: Classy Menus
	Description: Add custom CSS classes and id's to menu items
	Category: Navigation
	Dependencies: SchoolPointe.Menus, Vandelay.Classy

 placement.info 

<Placement>
  <!-- ... -->
  <Match ContentType="MenuItem">
    <Place Parts_Common_Owner_Edit="-" />
    <Place Content_SaveButton="-" />
    <Place Parts_CustomCss_Edit="Content:After;Alternate=Parts_CustomCss__MenuItem"/>
  </Match>
</Placement>
Basically, if I put a dependency on Vandelay.Classy on SchoolPointe.Menus, everything works fine.  But using it as I've put here, my alternate gets ignored.  Is there some way that I have to delineate that a placement is for a specific feature?

 

Coordinator
Mar 9, 2012 at 8:16 PM

Taking the dependency is basically telling Orchard the order of priority here. So if you don't take the dependency, it's undetermined, but if you do, you win, which is what you want, right? So I'm not quite sure in what way this is not the "right" way?

Mar 9, 2012 at 8:26 PM

The problem is, SchoolPointe.Menus shouldn't depend on Vandelay.Classy.  SchoolPointe.Menus.Classy does.  But if I only put the dependency on SchoolPointe.Menus.Classy, my placement.info doesn't take effect.

Coordinator
Mar 9, 2012 at 10:22 PM

Well, if it shouldn't depend on it, its placement should not make reference to it... Shouldn't this placement file be in your theme instead?

Mar 9, 2012 at 11:01 PM

Lol, sorry, seems like we're missing each other.  I'm trying to add an optional second feature to my menu module, so that people can add custom classes and such to the menu items, but I wanted to leverage Vandelay.Classy instead of writing it myself.  So the core feature does not depend on it. The secondary feature does depend on it, which is why I'm trying to put a dependency in there, however it gets ignored unless I put the dependency on the core feature.  

As for putting it in my theme...this is an admin-side modification...and sure a user could make the modification themselves or something along those lines, but the classy editor is just massive and is way too cumbersome for this use case.  This screenshot comparison should show you what I mean:

Coordinator
Mar 9, 2012 at 11:36 PM

Oh, that would be a bug then.