We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40092
    • 265 Posts
    Hi All/Bruno,

    I'm finding my way around migxdb and loving it so far.

    I was wondering though, i have several tabs on formtabs, one of 'em is for thumbnail upload and displaying that thumbnail.
    I am building an existing site from Evolution to revolution, wisch so comes with the fact i have a structure of image folders.

    Right now when setting the tab on image-TV it defaults to the web root, where is obviously nothing to display.
    Can i set that default to rootsite/upload/foto/ ?

    And, later, to push it up a notch, i have another field, Pictures, from wich i would want to fetch and upload(and write to database) pictures to the same folder as mentioned above. Problem(for me) is that those pictures reside in a different table, connected on the main_id.

    Regards

    This question has been answered by multiple community members. See the first response.

    [ed. note: thapriest86 last edited this post 13 years, 7 months ago.]
      • 4172
      • 5,888 Posts
      Right now when setting the tab on image-TV it defaults to the web root, where is obviously nothing to display.
      Can i set that default to rootsite/upload/foto/ ?

      you can create a mediasource which points to that path.
      Then, in the migx-configuration for this image-field add this mediasource-id
      for the contexts web and mgr

      the file-browser should now open to this path for your image-field.
      to display your image in the frontend you will need to add the path to your image-placeholder.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 40092
        • 265 Posts
        Quote from: Bruno17 at Mar 11, 2013, 09:17 AM

        you can create a mediasource which points to that path.
        Then, in the migx-configuration for this image-field add this mediasource-id
        for the contexts web and mgr

        Wow, that was easy. smiley
        Thanks again for a swift reply to my first question, hope you can point me in the right direction for second as well. ;-)
          • 4172
          • 5,888 Posts
          And, later, to push it up a notch, i have another field, Pictures, from wich i would want to fetch and upload(and write to database) pictures to the same folder as mentioned above. Problem(for me) is that those pictures reside in a different table, connected on the main_id.

          its possible to use a MIGXdb - TV inside your form and connect records automatically to another table.
          the connected table should have a defined relation in the xpdo-schema.

          the other way could be, just to have a text-field with a MIGX-TV for the images on it.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 40092
            • 265 Posts
            its possible to use a MIGXdb - TV inside your form and connect records automatically to another table.
            the connected table should have a defined relation in the xpdo-schema.


            Good to know that it is possible, however, i have no clue as to how i would define the relationships.

            There is so much to configure and honestly i would not knwo how to begin. I see Joins in MigxDB-Settings, browsing the forums i see some complex(to me) code, that i think is doing something with the xml schema.
              • 4172
              • 5,888 Posts
              what's your existing xpdo-schema for your 'main-table' and 'images-table' ?
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 40092
                • 265 Posts
                Stripped down a little, because there are more 'tables' in the original.

                <?xml version="1.0" encoding="UTF-8"?>
                <model package="abc" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
                
                <object class="Accomodations" table="accomodations" extends="xPDOSimpleObject">
                		<field key="code" dbtype="varchar" precision="100" phptype="string" null="false" />
                		<field key="land_id" dbtype="int" precision="11" phptype="integer" null="false" />
                		<field key="alias" dbtype="varchar" precision="250" phptype="string" null="false" />
                		<field key="naam" dbtype="varchar" precision="200" phptype="string" null="false" />
                		<field key="plaats" dbtype="varchar" precision="200" phptype="string" null="false" />
                		<field key="intro" dbtype="varchar" precision="250" phptype="string" null="false" />
                		<field key="vanafPrijs" dbtype="decimal" precision="9,2" phptype="float" null="false" />
                		<field key="numberDays" dbtype="int" precision="10" phptype="integer" null="false" />
                		<field key="infoAlgemeen" dbtype="text" phptype="string" null="false" />
                		<field key="infoFaciliteiten" dbtype="text" phptype="string" null="false" />
                		<field key="infoAccomodatie" dbtype="text" phptype="string" null="false" />
                		<field key="klasse" dbtype="decimal" precision="5,1" phptype="float" null="false" />
                		<field key="soort" dbtype="varchar" precision="100" phptype="string" null="false" />
                		<field key="type" dbtype="varchar" precision="250" phptype="string" null="false" />
                		<field key="details" dbtype="text" phptype="string" null="false" />
                		<field key="thumbnail" dbtype="varchar" precision="200" phptype="string" null="false" />
                		<field key="active" dbtype="int" precision="1" phptype="integer" null="false" />
                		<field key="lastminute" dbtype="int" precision="11" phptype="integer" null="false" />
                		<field key="aangemaakt" dbtype="int" precision="11" phptype="integer" null="false" />
                		<field key="gewijzigd" dbtype="int" precision="11" phptype="integer" null="false" />
                		<field key="reisSoorten" dbtype="text" phptype="string" null="false" />
                		<field key="accomodatieTypes" dbtype="text" phptype="string" null="false" />
                		<field key="offer_price" dbtype="decimal" precision="9,2" phptype="float" null="false" />
                		<field key="video" dbtype="varchar" precision="200" phptype="string" null="false" />
                		<field key="losse_prijs" dbtype="decimal" precision="9,2" phptype="float" null="false" />
                		<field key="meta_beschrijving" dbtype="text" phptype="string" null="true" />
                		<field key="meta_zoekwoorden" dbtype="varchar" precision="500" phptype="string" null="true" />
                		<field key="zoover" dbtype="int" precision="1" phptype="integer" null="true" />
                		<field key="dag_prijs" dbtype="decimal" precision="9,2" phptype="float" null="false" />
                		<field key="klm" dbtype="tinyint" precision="1" phptype="integer" null="false" />
                	</object>
                
                	<object class="Images" table="images" extends="xPDOSimpleObject">
                		<field key="idAccomodation" dbtype="int" precision="10" phptype="integer" null="false" />
                		<field key="filename" dbtype="varchar" precision="200" phptype="string" null="false" />
                		<field key="omschrijving" dbtype="varchar" precision="250" phptype="string" null="false" />
                		<field key="aangemaakt" dbtype="int" precision="11" phptype="integer" null="false" />
                		<field key="sort" dbtype="int" precision="11" phptype="integer" null="false" />
                	</object>
                </model>
                
                  • 4172
                  • 5,888 Posts
                  your schema should look like this:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <model package="abc" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
                   
                  <object class="Accomodations" table="accomodations" extends="xPDOSimpleObject">
                          <field key="code" dbtype="varchar" precision="100" phptype="string" null="false" />
                          <field key="land_id" dbtype="int" precision="11" phptype="integer" null="false" />
                          <field key="alias" dbtype="varchar" precision="250" phptype="string" null="false" />
                          <field key="naam" dbtype="varchar" precision="200" phptype="string" null="false" />
                          .
                          . 
                        
                          <composite alias="Images" class="Images" local="id" foreign="idAccomodation" cardinality="many" owner="local" />   
                  
                      </object>
                   
                      <object class="Images" table="images" extends="xPDOSimpleObject">
                          <field key="idAccomodation" dbtype="int" precision="10" phptype="integer" null="false" />
                          <field key="filename" dbtype="varchar" precision="200" phptype="string" null="false" />
                          <field key="omschrijving" dbtype="varchar" precision="250" phptype="string" null="false" />
                          <field key="aangemaakt" dbtype="int" precision="11" phptype="integer" null="false" />
                          <field key="sort" dbtype="int" precision="11" phptype="integer" null="false" />
                      
                          <aggregate alias="Accomodation" class="Accomodations" local="idAccomodation" foreign="id" cardinality="one" owner="foreign" /> 
                  
                      </object>
                  </model>
                  


                  then put in your formtabs of Accomodations a new field, give it a name of a non-existing field,
                  for example 'images'

                  inputTVtype: migxdb
                  configs: accomodationimages

                  then create a new configuration: accomodationimages
                  put the details for this table into this configuration

                  on MIGXdb - Settings - tab

                  joinalias: Accomodation
                  you can choose Load Grid: auto

                  be sure you have:
                  check resource: yes
                  - this does the filtering by the main-record and creating the children-record's main-id (idAccomodation) on saving


                  this should do it. Tested it on mine and was working.






                  [ed. note: Bruno17 last edited this post 13 years, 7 months ago.]
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 40092
                    • 265 Posts
                    Thank you Bruno, this makes about 50% sense to me, the other 50% i will learn. ;-)

                    On mine it does not work, it keeps throwing tis error(there is no resource_id, so i don't knwo why it is trying to call it)

                     [2013-03-12 03:56:06] (ERROR @ /assets/components/migx/connector.php) No foreign key definition for parentClass: Accomodations using relation alias: Files
                    [2013-03-12 03:56:09] (ERROR @ /assets/components/migx/connector.php) No foreign key definition for parentClass: Accomodations using relation alias: Accomodation
                    [2013-03-12 03:56:09] (ERROR @ /assets/components/migx/connector.php) Error 42S22 executing statement: 
                    Array
                    (
                        [0] => 42S22
                        [1] => 1054
                        [2] => Unknown column 'Accomodations.resource_id' in 'where clause'
                    )
                      • 4172
                      • 5,888 Posts
                      did you run 'parse Schema' again, after doing your changes in the xpdo-schema?

                      also, may be I did changes on the update.php and getlist.php - processors, since the latest official release.

                      https://github.com/Bruno17/MIGX/tree/master/core/components/migx/processors/mgr/default

                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!