Theme for Search results page? Error Generating Alternate

Topics: Customizing Orchard, Installing Orchard, Troubleshooting, Writing themes
Apr 12, 2012 at 4:39 AM

I have search enabled and I want to override some basic visuals.  Trying to generate an alternate through the normal means ends up with an exception when I try to create:

~/Themes/My.Theme/Views/Zone-url-search.cshtml

"2012-04-11 23:30:19,308 [20] Orchard.Exceptions.DefaultExceptionPolicy - The relative virtual path 'Orchard.Core.Shapes.CoreShapes::Zone' is not allowed here."

I can see the css classes and could just override those to give me some flexibility but I was hoping to have a new cshtml like I could for anything else.

Anything I'm missing?  Any other work around.

Apr 13, 2012 at 2:02 AM

Any ideas?

Coordinator
Apr 13, 2012 at 5:02 AM

Why don't you create the alternate manually rather than by relying on shape tracing to do it for you?

Apr 15, 2012 at 3:16 PM
Edited Apr 15, 2012 at 3:18 PM
bertrandleroy wrote:

Why don't you create the alternate manually rather than by relying on shape tracing to do it for you?

Thanks.  I tried that a couple of different ways:

These are just ignored:

  • Views/Content-Search.cshtml
  • Views/Search/index.cshtml
  • Views/Content-url-search.cshtml

Then I tried the alternatives that Orchard actually provides:

  • Views/Zone-Content-url-search.cshtml
  • Views/Zone-url-search.cshtm

But that is for the zone itself and perhaps I could reach into the Content Item and display it but I couldn't figure that out.

The Search Module itself has a file located at View/Search/index.cshtml; and this is definately what is driving the content display.  I was surprised to find that  by trying to override that exact path in my theme did not work.  Is that a bug? (or just a feature request for the module itself?)

The work around right now is a heavy css customization of the following classes:

  • content-items
  • search-results

As well as a modification to the Orchard.Search module itself to add some additional CSS styles around the title and other items to give me more flexibility in how the results are displayed in a theme.

Any additional tips or advice?  Thanks for the continued assistance.


Coordinator
Apr 15, 2012 at 11:39 PM

Try Views/Orchard.Search/Search/index.cshtml.

Apr 16, 2012 at 12:12 AM
bertrandleroy wrote:

Try Views/Orchard.Search/Search/index.cshtml.

Worked like a charm.  Thanks for the assistance.  That pattern would appear to follow for any module.

Since I'm on the topic, overriding admin pages would be the same?

Finally one more, if I create a custom content type through the UI and wanted to override the admin area to make it a little bit more organized, how would I do that?

(Content Type)
      <Slide ContentTypeSettings.Creatable="True" ContentTypeSettings.Draftable="True" DisplayName="ButtonTextLink">
        <CommonPart OwnerEditorSettings.ShowOwnerEditor="True" DateEditorSettings.ShowDateEditor="False" />
        <ContainablePart />
        <BodyPart />
        <TitlePart ContentPartSettings.Attachable="True" />
        <AutoroutePart ContentPartSettings.Attachable="True" />
        <Slide />
        <CustomPropertiesPart />
      </Slide>

(Fields on it)

      <Slide ContentPartSettings.Attachable="True">
        <Image.MediaPickerField DisplayName="Image" />
        <Header.TextField />
        <SubHeader.TextField />
        <Link.LinkField />
      </Slide>

 

Coordinator
Apr 16, 2012 at 3:53 AM

No overriding admin templates is a bit more complicated because the admin theme has a higher priority. You'd need to make your own theme higer pri than even that, which is possible, but also means you need to override *everything* that's in the default Orchard theme (because then it's as if that didn't exist).

Apr 16, 2012 at 4:00 AM
bertrandleroy wrote:

No overriding admin templates is a bit more complicated because the admin theme has a higher priority. You'd need to make your own theme higer pri than even that, which is possible, but also means you need to override *everything* that's in the default Orchard theme (because then it's as if that didn't exist).

Thanks again for the help.  I did create my own theme and used this method to override:

http://orchard.codeplex.com/discussions/258854

        public ThemeSelectorResult GetTheme(RequestContext context)
        {
            if (AdminFilter.IsApplied(context))
            {
                return new ThemeSelectorResult { Priority = 110, ThemeName = "MyTheme.Name" };
            }

            return null;
        }
Using this method I was able to create a few cshtml's without having to 100% override things...then again, I was mostly playing with styles, not really hard core override of content admin.  No response needed.  Thanks for all your help!