Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete example of creating a new pagetype/archivetype #48

Open
michaelrall opened this issue Sep 17, 2020 · 1 comment
Open

Complete example of creating a new pagetype/archivetype #48

michaelrall opened this issue Sep 17, 2020 · 1 comment
Labels
question Further information is requested

Comments

@michaelrall
Copy link

Hello,

I'm trying to create a custom archive + post type for a FAQ-Area on my site (razor pages).
Following the docs I created a FAQArchive and an FAQPost

namespace landingpage.Models.PageTypes
{
    [PageType(Title = "FAQ Archive", UseBlocks = false, IsArchive = true)]
    public class FAQArchive : Page<FAQArchive>
    {
        public PostArchive<FAQPost> Archive { get; set; }
    }

    //var model = await api.Pages.GetByIdAsync<SimpleArchive>(id);
    //model.Archive = await api.Archives.GetByIdAsync<SimplePost>(...);
}
namespace landingpage.Models.PostTypes
{
    [PostType(Title = "FAQ Entry")]
    public class FAQPost : Post<FAQPost>
    {
    }
}

I can create a page with the FAQArchive-Type and add posts of type FAQPost - so far, so good.

Now when I navigate to the page (either preview or not) the page stays empty. I already tried to create a custom .cshtml file for my types but with no success.

So what is missing to complete my task ?? Do I need to setup some routing? Where would I place the view markup to have a custom rendering of my archive and its posts?

kind regards

@tidyui
Copy link
Member

tidyui commented Dec 1, 2020

Hi there. By default all pages are routed to ~/page, all posts to ~/post and all archives to ~/archive. To add a specific route for a content type you either use the PageTypeRouteAttribute or PostTypeRouteAttribute. More information on this can be found in the documentation, here for page types: https://piranhacms.org/docs/content/pages

@tidyui tidyui added the question Further information is requested label Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants