Jump to content

Recommended Posts

Posted

Hey.

If I want to list something on a page, but the number of elements is variable, e.g. team members with name/position/pic/bio or events with topic/date/speakers etc. how would I do that?

Create a new page for each element (team member, event) and make sure that they don't show up in navigation with selectors? Or is there a better way?

Thanks,

Lars

Posted

Yup - you would create a template for team member and another for events and then create pages using those templates.

What I would do is create a new template with nothing but a title field and call it "Team Members" and another the same called "Events" and set the page to be hidden in its settings (therefore it won't show in navigation and nor will its child pages - hidden pages are excluded by default). Then under that page, use the relevant templates and create your team members and events.

It takes a while to wrap your head around the fact that pages aren't just pages, but once you get to grips with that the possibilities are limitless :)

  • Like 1
Posted

Thanks for your fast reply!

Why do you suggest the hidden parent? What is the advantage compared to making my team members or events hidden?

How does this structure work when searching though? I would of course want to include all fields in the search, but obviously display the e.g. events page where everything is listed when searched for and not the 'fake pages' ... ?

Posted

You could make the physical .php template of members and events redirect to their parent page where they're listed.

$session->redirect( $page->parent()->url );
Posted

Thanks!

Just saw there is an option to create templates without files ... can I not just do that instead for all the sub elements?

Posted

Sure you can, but then you would require to do the "redirect" stuff in your search result rendering. For example each page that is in the result that has one of those templates, you want to output the parent url instead of the found page.


$results = $pages->find("...");
foreach($results as $result){
if($result->template == "members" || $result->template == "events") $url = $result->parent()->url ;
...
}

But a nice side effect of using a php template with a redirect, is that if you edit a page and using "view" it redirects to the page it is listed. Without a php template you would have no "view" function anyway, but just to mention.

Also notice, that repeatable page elements are on roadmap and will come pretty soon. But using sub pages is the way to go for now.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...