Search

Hi all,

I know I might be thinking this up all wrong, but I need to do something very simple. I am building a website for a friend's restaurant, and I am setting it up so that his staff can edit the menu via the Symphony backend interface.

To do this, I have created a section for each typology of dishes, eg. Starters, Mains, Seconds, etc. Each of these sections contains the same fields (dish name, price, description, etc.). I made it so that it's both logical and easy for them to add new entries.

Now, my problem is that on the website I want to visualise one section a time, but I can't find a way to do that without having to create a page for each section (I have one Data Source for each section obviously). Ideally, I'd much prefer to have an URL Parameter to filter which Data Source I want to use, rather than binding each page to a specific Data Source.

I know I could easily solve this by having one single section that handles all of the dishes, and one field that contains the typology, but I think that would make it harder for the end-users to add new dishes (imagine having to select the typology for each and every dish vs selecting a typology and then adding all the dishes).

So I am wondering whether there is actually an elegant solution to this problem.

Thank you very much for reading this far, I really appreciate it!

EDIT: I just wanted to add that I could theoretically pull all the Data Sources in one page and then filter manually through the data (based on the URL Parameter), but I think that's out of the question as it's both more resource intensive and awkward.

You could do something like this page/sectionparam (where sectionparam is a parameter)

then attach all the necessary datasources to the "page" and check with xslt (choose) what section_param has been passed eg. for http://somefancyrestaurant.com/menu/starters the xsl bit could look like this:

<xsl:choose>
    <xsl:when test="/data/params/section_param = 'starters'">
        <xsl:apply-templates select="/data/starters-list/entry"/>
    </xsl:when>
    <xsl:when test="/data/params/section_param = 'mains'">
        <xsl:apply-templates select="/data/mains-list/entry"/>
    </xsl:when>
    <xsl:otherwise>
        <xsl:text>please choose a course!...</xsl:text>
    </xsl:otherwise>
</xsl:choose>

edit: Don't worry it will be able to handle this...

ChriZ,

Thanks for your reply. I realise that I edited my original post as you were replying to me. Coincidentally, we had the same thing in mind, but I don't think it's a good practice to pull all the data from the DB when all I need is just a small set of it, especially when the menu can be very large. So I am looking for a solution that provides me with the exact data I need before it's sent to the front-end.

Thanks for your input anyway! :)

Believe me, it can cope with it no problem...

If you want your datasource to query different sections based on a parameter you'll have to customize it.

Yeah, I'm sure it can cope with it, but I just like to optimise the software as much as possible, since the website will be running on a very very resource-limited VPS.

As for customising the Data Source, I think it would be great, but I lack the necessary knowledge right now, and I was hoping for a built-in solution.

But if there are no alternatives, I might opt for your solution temporarily while I dig deeper into XSLT/XPath....

Thanks again :)

Well there would be another solution, but this would require an extra section. This would be a section with only one field: course so you would have 4 entries starters, mains, seconds, deserts,....

Then on all the other sections you would have a select box link which will point to one of those entries.

Then you would attach a datasource which queries that courses section with the param that you set this datasource will then output the id as a parameter (datasource chaining) which you can query all of the other datasources with!

edit: it would be more elegant to only have two sections then, courses and dishes (or whatever you would call that)

That could also be a solution, but it would add more complexity to the back-end, which I cannot really allow, as the end-users are not very computer savvy.

Another solution might be to make your own back-end with events, and use the select box method of assigning dish type in the Symphony back end. A good example of doing this is in one of the tutorials and in the default workspace - see here.

On your admin page you could have your list of dish types and nest existing dishes underneath with an add new button. Might require a little javascript and/or ajax magic to pull off depending on how you want to develop it. You could even just have basic links to dish types and add entries from there with a pre-filled dish type input field set to hidden. There's a lot of options when it comes to how you manage the UX/UI when you have more or less full control.

This is more complex than Chris's compromise (which as long as you're not managing thousands of dishes honestly will hardly tax even a 256mb VPS), but is probably the most thorough way to provide an admin interface that matches the client's expectations and/or skill level.

Yeah, having a custom back end is my long term plan, but right now I'm working on a very limited time frame, and what I'm doing is not a paid job, it's just a favour for a friend who had an unexpected necessity all of a sudden. That's why I was looking for the most basic solution around, without having to pull off a new UI from scratch.

Thanks for your input, s_e :)

P.S. The VPS has 160MB! :)

Well, I have a stupidly complex site (the first one I ever built in Symphony - total mess at the back) that spikes to ~60mb using apache as httpd and 50mb from mysqld (on windows no less) as long as it isn't doing JIT, when apache tends to go a bit bonkers and fly up to 100mb+ depending on the image in question.

Profile wise - even though I'm loading in about 20 DSs with up to 60 queries - the whole page generation takes around 0.3 seconds. This might be crippling on a high volume service site, but probably won't hurt a local restaurant site too badly. The ?profile param from the debug devkit is really handy for checking this out.

All that aside, apart from writing a custom datasource, you could see how the development on this (XSL Resource Loader) is going. At the moment I don't think it handles conditions, but it may well do soon, at which point you'll be able to use parameters to include data sources at the top of the template.. or not include them so to speak.

Edit: Oh also don't forget awesome superstar Nick Dunn's Cacheable Datasource for even more exciting speed options.

Edit edit: That whole preamble was basically supporting Chris's idea of just using multiple datasources without filtering. I.e. It probably won't affect the efficiency of the site as horribly as you'd think, even if the technique is a little inelegant.

There's an extension made for exactly this!

@s_e

Thanks for the valuable info, I'll check that stuff out. The thing is that my VPS is not dedicated to just one website, and a WordPress deployment is in the works, which is what worries me really.

@creativedutchmen

Cool! I'm gonna check it out! Thanks a lot! :)

Oh wow I totally forgot about that Huib. I'd heard of the extension but absolutely forgot what it did.

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