Search

I’m trying to figure out the best way of selecting a bunch of entries. Here’s the structure for my language system:

  • Languages, has many Translations.
  • Translations, has many Groups, a single Language and a single Element
  • Groups, has many Pages and Translations
  • Elements, has many Translations

My plan is to attach a set of translations to the page accessed via $labels/element-name. The query for this would essentially be: select everything from translations where the translation belongs to a group that is either available to all or assigned to the current page, and where the translation’s language is the currently selected language. I’m not sure which way to perform this; I have attempted to do it via datasources to limited success so far, as I can’t figure out how to perform a query like: “WHERE page LIKE {$root-page} OR {group/available-to-all} = TRUE”.
If I was to alternately go down the route of running the query directly in the extension, how and where would I perform it?

Sorry if it’s a little convoluted, hopefully it makes sense!

Sounds like this would be most easily achieved via a custom DS. You’d create a basic DS calling on your translations section, and then go in and edit the file itself.

Hrm yes this sounds quite tricky. If you add multiple filters to a Data Source they work together as AND and not OR. I would suggest either simplifying your data model significantly, or using a custom Data Source.

Start by creating a normal Data Source then modify the generated PHP file. The work is done in the grab() function. This function should return XML, either as a string or Symphony’s own XMLElement object.

A custom datasource seems to be the way to go then. I’m sure there must be an extension around that has an example of a custom DS being used, any ideas? :)
And thanks for the help chaps!

Bizarrely, I can’t think of one off the top of my head.

Nick, didn’t you once write a custom DS for generating some sort of tag cloud?

Knowledge! You know me better than I.

http://getsymphony.com/community/discussions/517/#position-4

You can access a MySQL connection and Symphony’s own MySQL class through $this->_Parent->Database. Just remember that any recordsets you return, you’ll also need to iterate over and build XML.

Symphony’s database structure is extremely normalised. Each Symphony field has its own table, meaning that if you want to retrieve a single entry you will need to join its relevant field tables together in your SELECT. yourheropaul wrote Database Manipulator to ease this pain, providing a more SQL-like layer on top of these joins. Unfortunately it is not yet documented beyond my example.

Awesome, thanks for that guys. The database manipulator looks very concise too, I’ll have to experiment with the best (easiest) option once I have the time!

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