Jump to content

How to select "similar pages" from a list ?


teo74
 Share

Recommended Posts

Hi all,

I'm new to ProcessWire. How could I select from a list of pages (from the backend) to create a list of "similar pages"? 

Maybe InputfieldPageListSelectMultiple.module(?) but I cannot find any information how to use this module.

Then store the list (by id?) in some field assigned to the current page  to be parsed when the page is rendered and show the similar pages. 

Thank you!!

Edited by teo74
Link to comment
Share on other sites

Hi teo74, welcome to the forum :)

You are sort of there with InputfieldPageListSelectMultiple - but alone, that is just one method of providing the visual input part of what you need. What you need is the Page fieldtype, which will give you the option of using Page List Select inputs, amongst others, in the backend.

The Fieldtype is how the data is stored, formatted and linked internally, and the Inputfield is how this field is presented and manipulated in the backend by a user.

Have a look at this video - Using the Page Fieldtype - to get an idea of how it all works.

In summary:

  1. Create a new field (called 'related', perhaps?) using the Page fieldtype.
  2. Configure it for the types of pages you want to select, and how you want the selector to look (which Inputfield to use)
  3. Add it to the template where you want to choose related pages.
  4. Edit those pages and choose the related pages

In those pages, you can get the related ones, and display the links, by doing something like this in the template code:

<ul>
<?php
foreach ($page->related as $relatedPage) {
    echo "<li><a href='{$relatedPage->url}'>{$relatedPage->title}</a></li>";
}
?>
</ul>
  • Like 3
Link to comment
Share on other sites

Wow, thank you Craig for the fast and good answer!

For those like me new to ProcessWire is really important get help when we're stucked. I really appreciate it !!  :)

Again, thank you very much !  :)  :)

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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