Search

You need to output a parameter for the data source that links the two; output parameter for an album data source that then filters the band and label data sources.

It sounds like you need to reverse the relationship. The band entries need to have a section link to the album and the label entries need to have a section link to the album. Then for the album data source output parameter “System ID” and filter the section link fields with this output parameter in band and label data sources.

There, pay me :-)

@phoque: I’ve only glossed over your stuff but perhaps the Bi-Link field is what you need?

Everything in reverse with “select multiple”? Feels like a hack to me, because relational databases don’t work like that.

Why can’t the select box link create a optgroup in the “XML output” section of the DS-editor, put all fields of the linked section in it and make all of them selectable too? It would make complete sense if you think of it as a JOIN.

Why can’t the select box link create a optgroup in the “XML output” section of the DS-editor, put all fields of the linked section in it and make all of them selectable too? It would make complete sense if you think of it as a JOIN.

It would be a great feature for other extensions as well - but I think this idea conflicts with the way the javascript of the data source editor works at the moment.

Oh, right. It’s already using <optgroup>, wich you cannot nest. Then something similar. :-)

To me, this whole “Use a comfortable field to link sections. And then create duplicate datasources, feed one with the values of the other and fiddle everything together in the XSLT” doesn’t feel right. The select box link field should simply offer you to select the foreign fields as well.

<albums>
    <entry>
        <title>The Hawk is Howling</title>
        <length>63:29</length>
        <release>2008</release>
        <bands> <!-- this is automatically provided by the select box link field -->
            <entry>
                <name>Mogwai</name>
                <homepage>http://www.mogwai.co.uk/</homepage>
            </entry>
            <!-- in case you have "select multiple" enabled, 
                there are more than one entry -->
        </bands>
        <labels>
            <entry>
                <name>Rock Action Records</name>
                <homepage>http://www.rock-action.co.uk/</homepage>
            </entry>
        </labels>
    </entry>
    ...
</albums>

This is not a rant, I am just trying to encourage a debate on priciples here. :-)

The select box link field should simply offer you to select the foreign fields as well.

My new Mediathek field works like that - it’s not that hard to implement. But due to the “option group problem” in the data source editor you need to specify the included fields in the field settings.

I really would love to see a better implementation system wide.

It sounds like you need to reverse the relationship.

It just came to my mind: That would make creating events a lot harder. If not impossible at all.

The Bi-Link field will create a similar XML for you, phoque. In the XML Output the Bi-Link field adds three output options (count, items and entries) so you can choose the type of XML that is returned.

Perhaps this is something that could be built into the Select Box Link field. However I would be cautious about adding this since building this XML requires considerably more database queries. I like the idea of very granular Data Sources. Sub nodesets of other sections muddies the water of a Data Source selecting from one section only. Maybe multiple output parameters from a single Data Source would solve your solution.

relational databases don’t work like that.

Interesting point. It sounds like Allen’s suggestion will work :-) I’m going to look into this extension myself!

Is there a possibility of adding an option, maybe a checkbox, that gives you the option to order the select box items by a specific field?

Right now I think it’s ordering the ID’s in descending order. I hope this is a reasonable request.

Thanks for your help.

– BZ

Is there a possibility of adding an option, maybe a checkbox, that gives you the option to order the select box items by a specific field?

I made this change the other day but Alistair hasn’t acknowledged my pull request yet. I modified the field so that:

  • the order of the Sections adhere to the drag-and-drop order on the Publish > Sections page (commit)
  • the order of entries adhere to the sort order of entries in that section. So by default they are in system date order, but if you sort the table by another field (a Date, or an Order Entries field for example) this will be honoured by Select Box Links pulling from this section (commit)

If you want to give this a go grab my field.selectbox_link.php from Github and replace it with the one you have already (making a backupp first!). You won’t need to re-Enable the extension.

Wow! Thank you Nick!

I did exactly what you said. I backed up the original version of Select Box Link field (field.selectbox_link.php) and replaced that one file with your version on github.

It works marvelously. This is so helpful. Thank you so much for your help!

This extension works great. I’m using to import a massive xml with options for webshop items to be customized.

I’m missing one thing though, when using ‘show column’ the value does not show op in the entries overview?

Never mind the above, I posted on the wrong extension ;)

I edited your extension a bit to enable filtering for handles on linked sections aswell.

For instance, I have a photo’s section, linked to an albums section. I wanted to be able to display only the photo’s of a particular album, and display the handle in the url (as a param).

I am not really comfortable with github, so please forgive me for posting the modified code here.

All changes are made in field.selectbox_link.php

Right after

function buildDSRetrivalSQL($data, &$joins, &$where, $andOperation=false){
    $field_id = $this->get('id');

I added:

            foreach($data as $key => &$value){

                //for now, I assume string values are the only possible handles.
                //ofcourse, this is not entirely true, but I find it good enough.
                if(!is_numeric($value)){
                    //numeric returned false, so the value is in fact a handle, not an id.

                    //replace the handle with it's id, for processing in the database.
                    //I wanted to do this in one query, but since the result from the first becomes a table of the second, this is not possible..
                    $return = Frontend::instance()->Database->fetchRow(0,"select related_field_id from `sym_fields_selectbox_link` where field_id='$field_id' LIMIT 1");
                    $return = Frontend::instance()->Database->fetchRow(0,"select entry_id as id from `sym_entries_data_{$return['related_field_id']}` where handle='$value' LIMIT 1");
                    $value = $return[id];
                }

            }

Do you use Github? If so, I strongly recommend forking Alistair’s code and submitting this as a patch. This is dead handy! I wonder if it could be abstracted so that it doesn’t rely on a handle column since the linked field might not always be an Input field (although 99% of the time it is).

Do you use Github? If so, I strongly recommend forking Alistair’s code and submitting this as a patch.

I do use it, I’m just not really comfortable with it yet.

This will be my first fork, woohoooo!

I’m still not really sure if I like github or not..

I just updated a site from *cough* Symphony 2 beta to the current release. It uses the very old sectionlink field that has been replaced by this extension with the launch of Symphony 2 stable.

Does anybody know if there is an easy way to migrate from sectionlink fields (used to connect blog entries and comments) to select_box_link fields?

Not that I know of. Your best best is probably to write a PHP script to migrate the tables…

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