We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32347
    • 143 Posts
    I want to be able to place different image on pages through the template design? It will be located in the header are of the template. I want to to change out on the different pages. What would be some of my options?

    thanks
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Sounds like an image-type TV is what you want.
        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
        • 32347
        • 143 Posts
        can I use TV's and make a list with check boxes for a certain image for that particular page?

        thanks
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Use a Media Source to specify the folder with the images. Assign the Media Source to an image TV. The image TV in each resource will allow the editor to select the image for that page.
            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
            • 32347
            • 143 Posts
            Thanks


            Quote from: sottwell at Aug 08, 2014, 08:35 PM
            Use a Media Source to specify the folder with the images. Assign the Media Source to an image TV. The image TV in each resource will allow the editor to select the image for that page.
              • 32347
              • 143 Posts
              I have the media source working along with the TV attached tot he media source. The TV is showing up on the page, but the files are not showing up in the list box in the TV tab on the page.

              I have been looking for the resolution for hours, but have yet to find one. Question.... Do I have to manually list the files in the TV or in the media source? OR shouldn't the media source put the information into the list box?

              Thanks


              Quote from: sottwell at Aug 08, 2014, 08:35 PM
              Use a Media Source to specify the folder with the images. Assign the Media Source to an image TV. The image TV in each resource will allow the editor to select the image for that page.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                This is what you should see when you edit the resource's TV, and when you click the arrow on the right. You can upload files from the image browser.

                And here is the Media Source this particular TV is using. It has a dynamic path based on the user editing the resource. It's for a system where each user edits his own group of resources. In general, a path and URL like
                assets/images/

                would be sufficient.
                  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
                  • 40045
                  • 534 Posts
                  If you really want to use a listbox to select the files, you would have to do that with a custom snippet (lets say setFileListboxTV) that fetches the files inside a defined folder. You would have to create a listbox TV and in the input options field add an @EVAL statement to execute the snippet that get's the files you want to list. Could be something like that:

                  <?php
                  // use with @EVAL return $modx->runSnippet('setFileListboxTV', array('sourceid' => 2, 'folder' => 'media.test'));
                  $sourceid = 2;
                  $folder = 'media.test';
                  $modx->loadClass('sources.modMediaSource');
                  $source = modMediaSource::getDefaultSource($modx, $sourceid);
                  
                  if (!empty($source)) {
                  	$source->initialize();
                  	$files = $source->getObjectsInContainer('media.test');
                  	$list = array('Choose File...==');
                  
                  	foreach ($files as $file) {
                  		$list[] = $file['name'] . '==' . $file['fullRelativeUrl'];
                  	}
                  
                  	return implode('||', $list);
                  }