Sign in

Custom post template

  • This topic has 3 replies, 2 voices, and was last updated 9 months, 1 week ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3403
    [anonymous]

    Hello, first, a big thanks to the developers of Publii,
    I am currently discovering the CMS and I already like the whole concept!

    I’m not a developer, don’t blame me if my questions may seem absurd,
    I promise not to abuse 😉

    I want to set up simple navigation on the home page:
    A list of projects, and a list of blog posts, each in a separate section.

    I think I understood that we could simulate the creation of pages by checking “hidden” on the post
    so that it is not listed with the other posts.
    These posts will be used for projects.
    I also created a custom template (project_page) for the projects.

    My question is what is the best way to display/list only the project pages in a separate section on the
    site home page:

    I had thought of something like this:

    {{#each project_page}}
    <h2>
    

    {{title}}

    </h2>
    {{/each}}

    But without success.

    Thank you for any tips,

    #3404
    Bob

    Hi Constantin,

    The “post templates” should be used to change the layout structure and post options.
    In your situation, you should base on tags and display their list of posts; for example, use the “project” tag for all your project posts and display these posts within this tag on the front page with {{#getPostsByTags}} helper https://getpublii.com/dev/getpostsbytags-helper/#new-syntax-034

    Hope this helps.

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #3405
    [anonymous]

    Hello Bob,

    thank you for your reply,

    Yes, reading the doc awaiting for a reply, I found this solution that work fine.

    Is it the only way to “filter” this type of content? I was searching for something that allow me to not have to “hard write” the tag.

    #3406
    [anonymous]

    Ok, I found a solution witch works:

     

    {{#each posts}}
    {{#checkIf template '===' 'project_page'}}
    
    {{title}}
    
    {{/checkIf}}
    {{/each}}

     

     

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.