Search code examples
codeigniterpyrocms

Is it possible to display PyroCMS' Stream entries on separate pages and how?


I'm using PyroCMS's Entry Looping to display the entries of a stream on a listing page. I would also like to display each entry with more details on a separate details page.

It could be for example a list of reviews and each review has a separate page with more details.

Preferably the URL to the single details pages are search engine optimized containing keywords in the page URL and the details pages should be linked from the listing page.

Is that possible to realize with the Entry Looping functionality of the Streams module in PyroCMS and how?


Solution

  • Yes, that's possible. Next to "streams:cycle" there's also a "streams:single" plugin function, which is basically the same as cycle - just for single entries.

    You need 2 pages: 1 for cycling through all the entries which also generates a link to the details page, and then of course the page on which the details for a single entry should be displayed.

    Example of a page with a list of reviews and links to the detail page:

    {{ streams:cycle stream="reviews" }}
       {{ short_review }}
       <a href="{{ url:site }}reviews/details/{{ id }}">Read more</a>
    {{ /streams:cycle }}
    

    Note that the id of the entry is in the third segment. You can use "[segment_1]", "[segment_2]" in your stream parameters to get to those values (see http://docs.pyrocms.com/2.2/manual/plugins/streams/parameter-variables)

    Page "details", in this example a subpage of "reviews":

    {{ streams:single stream="reviews" id="[segment_3]" }}
       <h2>{{ title }}</h2>
       {{ full_review }}
    {{ /streams:single }}
    

    Make sure that you've disable the "Require an exact URI match?" option in the options tab of that page.