Search

I'm working with Symphony again after some time and I am wrestling with, I think, some fairly basis things.

I have created a Section Page content which basically allows me to link 'content' to Symphony Pages. This allows editors to create Page content Entries (title, text, images, etc).

Now I need to show some 'link blocks' to child-pages on some pages. If a Page contains children I need to display the Page Content(!) of those children on the parent page.

My initial thought was that I would be able to filter a DS of 'Page Content' entries where 'parent-page' equals {$current-page} (or {$current-page-id}. However: there is no param 'parent-page' available.

So I thought I needed to chain DS'es: first create a DS 'Subpages' based on Navigation that would output all child-pages and second use this DS'es $ds-subpages output param to filter my other 'Page Content' DS… But: a DS based on Navigation does not provide me with an output param…

I must be missing something since this seems fairly trivial. Any pointers?

I'm assuming that you are using the Page Select Box Field to link entries to pages. Does it need to be an implicit relation (through the page hierarchy)? Would an additional optional Page Select Box Field to explicitly define a link to a page be an option?

@Klaftertief correct, I use a Page Field.

Do you mean that I could add another ('explicit') Page Field to the PageContent section with the parent Page? This would work but sounds like a bit of a hassle for the user.

When an entry's Page is available it should not be too hard to establish its parent Page (if any) right? I feel explicitly having to choose/set it (when it's already 'set' on the Symphony Page) is a bit too much. The hierarchical structure (of Symphony Pages) is already available in my Navigation (-utility). All I need is some way to retrieve some Entries linked to the current Page's subpages (if any).

This must be a familiar pattern: on a Page I need to show an excerpt with link (Entries in a Page Content section) from the subpages.

My question, therefore, remains simply this: How do I retrieve linked Entries from a Page's subpages most easily?

Do you mean that I could add another ('explicit') Page Field to the PageContent section with the parent Page? This would work but sounds like a bit of a hassle for the user.

I had a setup like that in mind:

  • a "Page Content" Section for static content, using the Page Select Field to map entries to pages
  • a set of pages, some with a "Page Content" DS, some to display entries from other sections
  • each page for "Page Content" has a "headline" URL parameter
  • the "Page Content" section has a second Page Select Field and possible other fields (Input, SBL) to define links to other content (entries, pages, URLs)

So on a static page (with the "Page Content" DS) you can either show the full entry/entries or just excerpts. The excerpts link to either

  • the full entry using the "headline" URL parameter,
  • a (Sub)-Page using the second Page Select Field
  • an entry using the SBL
  • or somewhere else using the plain input field.

I hope this makes some kind of sense.

Hi @klaftertief. Thank you for your reply. I must say I do not quite follow your approach (forgive me :) ).

I decided to try and create a little custom DS for this. This works, teehee! (my first attempt)

Anyway, I'm quite sure some of you will LOL at my pathetic attempt… Any feedback is appreciated: http://pastebin.com/MjxYMg6H

This custom DS is aimed at my specific situation: I have a 'PageContent' Section, entries are linked with a Pages Field to Symphony Pages. On some pages I need to be able to list 'PageContent' entries of subpages

So: I attach my custom DS that queries PageContent entries with a 'page' field that points to subpages of the current page. This custom DS outputs a {$child-content-pages} that I use in a default PageContent DS.

@david, not that it really matters in this specific situation, but you should always surround variables in a query with apostrophes, to prevent SQL injection hacks.

An example could look like this:

$query = "SELECT handle FROM sym_pages WHERE parent = '".$parentPageId."' ORDER BY sortorder ASC";

if you are sure the $parentPageId is "safe", or

$query = "SELECT handle FROM sym_pages WHERE parent = '".General::sanitize($parentPageId)."' ORDER BY sortorder ASC";

if you are not sure.

Again, in this specific case this doens't make a difference, but if you ever want to make more advanced DS'es this is definitely something you should keep in mind.

@Huib thanks, you're right of course. I've added the quotes in my DS. Other things that could be better?

I believe your whole grab()-function could also be narrowed down to:

public function grab(&$param_pool){
    $param_pool['child-content-pages'] = 
        Symphony::Database()->fetchCol('handle', 'SELECT `handle` FROM 
        `sym_pages` WHERE `parent` = '.$this->_env['param']['current-page-id'].';');
}

Hi Giel, that works great (when only needing the $child-content-pages param)…

It's a whole lot neater indeed. Thanks!

For reference I've changed my complete DS in http://pastebin.com/rxtKYE8b

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details