We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19872
    • 1,078 Posts
    I have a migx set up that I have used many times for adding photos to galleries and web pages. I have a situation where I don't really need to have an image load into a web page, but rather output the full URL for each image file between <image></image> in an XML doc.

    I have about 60 resources under a container. That container has a pdoResources call that grabs contents from a bunch of other TVs. The last phase on the process is to be able to generate the proper markup for the final XML doc.

    So far, what I have developed is working as expected. Just trying to determine the best, quickest route to take to handle these image URLs. Maybe it's as simple as changing the output of MIGx so that instead of rendering an image, it renders the image URL as text.

    I was thinking MIGx might be the way to go because I could see thumbnails, and change the order of the image from withing the manager.

    Only other solution I can think of is to hand code the markup for the image and paste it into a TV text area.
    • Sounds like you are giving your image TV an output option of "image". Don't. You don't want the formatted TV output, you just want the raw value. Leave the output option at "default".
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 19872
        • 1,078 Posts
        Hi Susan:
        Thanks for responding. I'm in the thick of copying in some of my previously used migx set up. I do have MIGx output set to default. There is also another TV called image. It's input type is Image, and it's output was default as well. I wonder if there, I change output to be URL?

        I'll know a bit more in a few moments after I pop in some images and then take a look at the source code that gets generated.

        Thanks for your assistance earlier today. Very helpful. I just finished inputting data for 25 resources (about 40 TVs each — and all the content spools beautifully into one XML doc. Without MODx, I'd probably still be coding all that XML data by hand.
          • 19872
          • 1,078 Posts
          Oy! I think I need more tea. It's just occurred to me that with my resources, I have simple TVs. The values get pulled into the master container resource which is an XML doc. Pretty clean and simple.
          With these image URLs though, I am now stumped because each resource could have a different quantity of image URLs. One might have 5, another 15, some as much as 25. I can't write a unique TV to compesate for each image. That would be crazy.

          If I had all of the image paths and markup output in like a text area that would probably work. That way, there is only one TV to mess with.

          I might be close with this.

          My goal is to output this type of structure.

          <Images>
          <Image>http://www.......path-to-my-first-photo.jpg<image>
          <Image>http://www.......path-to-my-second-photo.jpg<image>
          <Image>http://www.......path-to-my-third-photo.jpg<image>
          and so on
          </Images>
          


          I have MIGx pared down to only deal with the image for now. I may add in another column so that I can type a notation along with each image for when I am managing. If the thumbnails are large enough though, I may not needs any notes.
          The Form Tab in my MIGx is:
          [
          {"caption":"Image", "fields": [
          {"field":"image","caption":"Image","inputTV":"image"},
          ]
          }

          And the Grid Column is:
          [
          {"header": "Image", "sortable": "false", "dataIndex": "image","renderer": "this.renderImage"},
          ]

          One Chunk to hold my Wrapper: mgPhotoContent
          <Images>
          [[getImageList? &tvname=`mgPhotos` &tpl=`mgPhotoContent`]]
          </Images>

          Got one to handle each image. mgPhotoContent
          <image>[[+image]]</image>

          And the image code needs to fall in a specific spot because the XML has to be in a specific order

          <BathroomNumber>[[+tv.79-BathroomNumber]]</BathroomNumber>
          <BedroomNumber>[[+tv.81-BedroomNumber]]</BedroomNumber>
          <Description>[[+tv.83-Description]]</Description>
          <Images>
              <Image>http://www.......path-to-my-first-photo.jpg<image>
          </Images>
          
            • 19872
            • 1,078 Posts
            Maybe I just set my MIGx TV call right there in the code?

            Giving that a try, and remembering also to put the name of that MIGx in my includeTVs and process TVs list of the pdoResources call.

            
            <BathroomNumber>[[+tv.79-BathroomNumber]]</BathroomNumber>
            <BedroomNumber>[[+tv.81-BedroomNumber]]</BedroomNumber>
            <Description>[[+tv.83-Description]]</Description>
            [[+tv.mgPhotos]]
            
              • 4172
              • 5,888 Posts
              some Tips.
              you don't need to have a helper-TV, when you use inputTVtype like:

              [
              {"caption":"Image", "fields": [
              {"field":"image","caption":"Image","inputTVtype":"image"},
              ]
              }


              And you can use &wrapperTpl like that:

              [[getImageList? 
              &tvname=`mgPhotos` 
              &tpl=`mgPhotoContent`
              &wrapperTpl=`@CODE:<images>[[+output]]</images>`]]


              Then the <images> - tags are only there, if there are any images

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

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 19872
                • 1,078 Posts
                After inserting [[+tv.mgPhotos]] in my TV, I went to the resource and I see the MIGx TV and clicked on Add Item, but the window that popped up is blank. No way to then navigate and find an image.

                  • 4172
                  • 5,888 Posts
                  if you are inside getResources, you will need this:

                  [[getImageList? 
                  &docid=`[[+id]]`
                  &tvname=`mgPhotos` 
                  &tpl=`mgPhotoContent`
                  &wrapperTpl=`@CODE:<images>[[+output]]</images>`]]
                  
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 19872
                    • 1,078 Posts
                    Hi Bruno:

                    Thanks for the tip. I'll give this a try.


                    Quote from: Bruno17 at Feb 28, 2016, 07:07 AM
                    some Tips.
                    you don't need to have a helper-TV, when you use inputTVtype like:

                    [
                    {"caption":"Image", "fields": [
                    {"field":"image","caption":"Image","inputTVtype":"image"},
                    ]
                    }


                    And you can use &wrapperTpl like that:

                    [[getImageList? 
                    &tvname=`mgPhotos` 
                    &tpl=`mgPhotoContent`
                    &wrapperTpl=`@CODE:<images>[[+output]]</images>`]]


                    Then the <images> - tags are only there, if there are any images

                    </images>
                      • 19872
                      • 1,078 Posts
                      My Container for all of these resouces is set to be an XML doc with an empty template.

                      I have pdoResources set up like this:

                      <?xml version="1.0" encoding="UTF-8"?>
                      <Properties>
                      [[pdoResources?
                        &tpl=`propertyData`
                        &parents=`3`
                        &depth=`10`
                        &limit=`100`
                        &includeContent=`1`
                        &includeTVs=`01-Adid,03-ExternalAgentid,05-ExternalBrokerid,07-HiddenAddress,09-Address1,11-City,13-State,15-Zip,17-Longitude,19-Latitude,21-Community,23-Country,25-Mls,27-ContactFirstName,29-ContactLastName,31-ContactAgencyName,33-ContactPhone,35-ContactAddress1,37-ContactCity,39-ContactState,41-ContactZip,43-ContactCountry,45-ContactEmail,47-ContactUrl,49-AddContactFirstName,51-AddContactLastName,53-AddContactAgencyName,55-AddContactPhone,57-AddContactAddress1,59-AddContactCity,61-AddContactState,63-AddContactZip,65-AddContactCountry,67-AddContactEmail,69-Brokerage,73-LotSize,75-PropertyType,77-MinPrice,79-BathroomNumber,81-BedroomNumber,83-Description,85-SqFt,mgPhotos`
                        &processTVs=`01-Adid,03-ExternalAgentid,05-ExternalBrokerid,07-HiddenAddress,09-Address1,11-City,13-State,15-Zip,17-Longitude,19-Latitude,21-Community,23-Country,25-Mls,27-ContactFirstName,29-ContactLastName,31-ContactAgencyName,33-ContactPhone,35-ContactAddress1,37-ContactCity,39-ContactState,41-ContactZip,43-ContactCountry,45-ContactEmail,47-ContactUrl,49-AddContactFirstName,51-AddContactLastName,53-AddContactAgencyName,55-AddContactPhone,57-AddContactAddress1,59-AddContactCity,61-AddContactState,63-AddContactZip,65-AddContactCountry,67-AddContactEmail,69-Brokerage,73-LotSize,75-PropertyType,77-MinPrice,79-BathroomNumber,81-BedroomNumber,83-Description,85-SqFt,mgPhotos`
                        &showHidden=`1`
                        &showUnpublished=`0`
                        &hideContainers=`0`
                      ]]
                      </Properties>
                      



                      Quote from: Bruno17 at Feb 28, 2016, 07:09 AM
                      if you are inside getResources, you will need this:

                      [[getImageList? 
                      &docid=`[[+id]]`
                      &tvname=`mgPhotos` 
                      &tpl=`mgPhotoContent`
                      &wrapperTpl=`@CODE:<images>[[+output]]</images>`]]