Render content on Homepage differently than rest of Site

Topics: Customizing Orchard
Feb 28, 2011 at 6:49 PM

It seems that the Homepage MUST have content or else it can't load. And it seems that you cannot stop the content from being shown on the Homepage. 

The thing is I don't need or want to show any specific content as such on my homepage, it has some HTML widgets, twitter and blog feeds etc, but I don't really want to show the content part. I feel stupid, but there must be a way to hide the content och render the content zone differently (with css) on the Homepage only?

Thanks for any help!

Coordinator
Feb 28, 2011 at 7:16 PM

You could use a different layout for the home page (http://weblogs.asp.net/bleroy/archive/2010/12/14/switching-the-layout-in-orchard-cms.aspx, something that you'll be able to do out of the box in 1.1) where the content zone is not rendered.

Feb 28, 2011 at 10:01 PM

Thanks for the tip. I already had a custom theme based on TheThemeMachine, so I just added the LayoutFilter.cs class to a /Themes/MyTheme/Filters/ folder I created (there were no such folder already). Then I created a new Views/Layout-HomePage.cshtml file and tried the homepage, but the old layout is still rendered, the new layout is never hit.

Did I miss something? Man, I hate cargo-cult-coding like this... the Orchard codebase is so huge it's hard to get a grip on it.

Coordinator
Feb 28, 2011 at 10:04 PM

In order for code in the theme to get compiled, you need the theme to have a [mytheme].csproj file.

Mar 1, 2011 at 8:13 AM

But I have a csproj file which was created for me with the codegen tool. But I'm working in the "hidden" folder inside the Orchard.Web project, is that wrong? 

Thanks for trying to help!

Coordinator
Mar 1, 2011 at 8:27 AM

What is the hidden folder inside Orchard.Web?

Mar 1, 2011 at 8:50 AM

I'm working with the full source code downloaded from Codeplex. Then I create my own Theme with codegen like this:

codegen theme MyTheme /BasedOn:TheThemeMachine /CreateProject:true /IncludeInSolution:true

This creates a "real" project called "MyTheme" and it also creates a "hidden" folder in the Orchard.Web project, under Themes folder. I'm editing and changing files in that "hidden" themes folder in the Orchard.Web project. Is that wrong? Should I edit files in the "real" project for my own theme? Changes I do there doesn't show in the web projects I guess until I reapply the theme from the dashboard, right?

Mar 1, 2011 at 9:28 AM

I got it working! I had to manually open up the .csproj file of my theme, then add this section:

  <ItemGroup>
    <Compile Include="Filters\LayoutFilter.cs" />
  </ItemGroup>

So now I can have my own Layout-HomePage.cshtml file where I have removed the Content zone :)

On to the next thing on the list... 

 

Nov 12, 2011 at 10:29 PM
Edited Nov 12, 2011 at 10:29 PM
JohanDanforth wrote:

I got it working! I had to manually open up the .csproj file of my theme, then add this section:

 

  <ItemGroup>
    <Compile Include="Filters\LayoutFilter.cs" />
  </ItemGroup>

 

So now I can have my own Layout-HomePage.cshtml file where I have removed the Content zone :)

On to the next thing on the list... 

 

The issue is that you didn't create the item and folder it was in within visual studio.  The step above wouldn't have been needed.  In fact, if all you did was add the file above....you are still in a bit of trouble because the folder is "hidden".  

 

PS> I like your direction on the hiding of the content page.  I'll be using that method for my own theme.  Thanks for the tips!