Search

The site I'm working on will have a couple of sections (blog, articles, photo etc.). To the front page, I want to choose a fixed number, let's say 9, of entries. If it was just a question about picking nine articles or nine blog posts and have them on the frontpage, adding a front page-field to the section and filter by it would probably have made the trick.

But I want to be able to mix'n'match from all sections. Say 4 blog entries, 1 article and 4 photos. I also want to have nine specific placeholders on the front page, so that I can choose where each entry will be.

To make things even worse, I want different stuff added to the final xml depending on what kind of section the entry is fetched from. For articles I want the header, for photos the caption and date etc, for blog entries header and number of comments.

And I've no idea on how to solve this.

Hmmmm..... Well there's no way to get around the fact that you'll need a separate DS for each section that you're drawing from, that's for sure. So your XML problem isn't really an issue because you'll be setting the output there.

As for the rest of it, still thinking...

Off the top of my head: maybe the quickest solution is to add two fields to your sections: a checkbox called "Promoted to Front Page" and a select box with your placeholder options like "feature box, sidebar, etc. etc."

You create DSes for each section (homepage-articles, homepage-blog-entries), each of which filters by the checkbox field and has a max of 9 results (to accommodate the extreme event that all your homepage items are from the same section).

The rest is XSL. For each placeholder, I think you'd match across the various DS XML sets where the placeholder is the correct value. This is probably not the right way to do it, but might give you the idea until Allen or someone can come along and verify:

 <xsl:apply-templates select="homepage-articles/entry[placeholder = 'feature'] | homepage-blog-entries/entry[placeholder = 'feature']" />

With this solution I think you'd have to be sure to have ONLY 9 items selected from across all your sections...

Anyway, that what I could come up with right now. Hope that's somehow helpful.

Here's another approach (only in theory, I haven't tried it out).

One DS for each section type (blog, photo, article etc.) as czheng suggests. Each DS selects the latest 9 entries, ordered by date. This guarantees that if there are no blogs or articles, you'd still have 9 photos to display.

Then use czheng's example with the "select" attribute selecting the entries from the various sections. Then you'll need to throw in an <xsl:sort> on the date field, and you should end up with a sorted combined list of all entries. While iterating through them (an <xsl:for-each> loop) you can check the node name, if it's a homepage-articles/entry then call the template to display an article, if it's a homepage-photos/entry call the template to display a photo.

Purely theoretical, but I think it might work.

So you want to combine all of your 'featured' entries together, iterate through them, and determine their type.

This introduces slight over-querying, since you could possibly select 27 entries and just display 9 of them (9 articles, 9 blog entries, 9 photos), but I don't think this is a huge overhead.

Hmm. The thing is that I don't want to be limited to the last nine entries in each category. czheng's way seems more suitable for my needs, and shows that what I want to do to is possible with Symphony. But my hope was that I could somehow have a frontpage section that just linked to the nine entries what are currently selected for the front page.

Perhaps an easier way -- create a new Section with a section link field that is linked to multiple sections. Your DS could then pull from this one section, doing all of the aggregation in the XML for you.

Let me see if I can tease out nickdunn's latest suggestion (which seems to be more what thoresson is looking for)... I was thinking of something like this yesterday but couldn't quite get my head around it. I believe (and correct me if I'm wrong, nickdunn) the suggestion is this:

1) Create a new section called, say Homepage Entries. It need only have two fields: placeholder, which is a select box that has nine your static presentation options, and entry, which as nickdunn suggests is a section link field that can point to any of the other sections you mention.

2) Create a DS called homepage-entries that sorts by system date, thus grabbing the 9 most recent Homepage Entries at any given time. Set the parameter output to entry (which is the System ID of the associated entries) so you have a way to grab the actual data from your other DSes.

As I think about it, I realize that this still seems to require all the other DSes. You'd need one each for the sections you're pulling from, each of which would filter by $ds-homepage-entries. And because the placeholder info isn't stored in the entries themselves (the articles or blog posts, for instance), you've got no direct way for your XSL to figure out what to put where... You'd have to do matching that was even more complex (if it's even possible). Is that right? My head is starting to hurt...

I know this isn't that constructive for thoresson's problem, but this type of situation is an argument for having a single section for all your content entries, and assigning a 'content section' or 'content category' to each entry, rather than a separate table/section for each content category. This assumes that your content entries take the same 'shape' in terms of fields.

Even if some of the fields overlap it isn't a huge problem - just include all the fields you think you will need and just only display the ones you want in each utility.

Also makes it easy to add or change categories in the future.

Henry, could you elaborate on your thoughts?

czheng, I just re-read your initial suggestion, and it seems to be something for me to build on.

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