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

    On the latest sites i’ve been building with modx 0.9.6.3 the image TV preview plugin that comes with the installation does not work,
    neither does the same function from the ManagerManager plugin. I simply cannot get the preview to work.
    I have checked the plugin execution order and even disabled every other plugin that might interfere.

    I have it working with manager on 0.9.6.2, but don’t want to have to downgrade while i’m building the site....

    Anyone else had this issue?

    Thanks,
    Ian
      • 7231
      • 4,205 Posts
      For me it works in 0963 but not in Evo 1.0rc2.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        It works fine for me on sottwell.com. I am using a custom Manager theme, though.

        It does not work on my local MAMP installation with the default MODxCarbon theme. The insert button is also not styled properly here, being a bar the width of the field underneath the field.
          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
          • 25663 MODX Staff
          • 12,272 Posts
          I just fixed and committed the Image TV Preview plugin for Evo. The manager TV form names were changed from using TV names (from the database rows) to their ids. The JS that did its mojo was looking for "tvSomeNameHere" instead of "tvX" where X is an integer corresponding to the unique ID of the actual TV instead of the name. Code follows for convenience:
          // <?php
          //    @name       ShowImageTVs
          //    @version    0.2.3, 9 Jul 2009
          //
          //
          //    @author     Brett @ The Man Can!
          //                rewritten by Rachael Black, update by pixelchutes and rthrash
          //                now works with MooTools and finds the image tvs itself
          //
          
          /* ---------------------------------------------------------------
          Instructions:
               Create a new Plugin and tick Documents > OnDocFormRender event.
               Make sure it is set to execute after any other plugin that
               could effect the template, like InheritParentTemplate. To edit
               the plugin execution order, from the manager go to Resources >
               Manage Resources > Plugins > Edit Plugin Execution Order by Event
               link. That's it. It should now show images of all image TVs.
          
               To configure image size, copy the following text (no leading spaces):
                 &w=Max width;int;300 &h=Max height;int;100
               into the plugin configuration and change values to suit
               This sets style="max-width: ; max-height: " for the image
               If you don't configure w or h, the image will be fullsize but
               you can add a css rule rule div.tvimage img {...} to the Manager Theme
          ------------------------------------------------------------------- */
          
          global $content;
          $template = $content['template'];
          $e = &$modx->Event;
          
          if ($e->name == 'OnDocFormRender' && ($template > 0)) {
          	$site = $modx->config['site_url'];
          
          	if (isset($w) || isset($h)) {
          		$w = isset($w) ? $w : 300;
          		$h = isset($h) ? $h : 100;
          		$style = "'max-width:{$w}px; max-height:{$h}px'";
          	}
          	else
          		$style = '';
          
          	// get list of all image template vars using TV ids from Evo
          	$table = $modx->getFullTableName('site_tmplvars');
          	$result = $modx->db->select('id', $table, "type='image'");
          	$tvs = '';
          	while ($row = $modx->db->getRow($result))
          		$tvs .= ",'" . $row['id'] . "'";
          	$tvs = substr($tvs, 1);		// remove leading ','
          
          	$output = <<< EOT
          <!-- ShowImageTVs Plugin :: Start -->
          
          <script type="text/javascript" charset="utf-8">
            var imageNames = [$tvs];
            var pageImages = [];
          
            function full_url(url)
            {
          	new_url = (url != '' && url.search(/http:\/\//i) == -1) ? ('$site' + url) : url;
          	return ( ( new_url.search('@INHERIT') == -1 ) ? new_url : new_url.replace( new RegExp(/@INHERIT/ig), '' ) ); // Update by pixelchutes
            }
          
            function checkImages()
            {
              for (var i = 0; i < pageImages.length; i++) {
              	var elem = pageImages[i];
                var url = elem.value;
                if (url != elem.oldUrl) {
               	  elem.thumbnail.setProperty('src', full_url(url));
               	  elem.thumbnail.setStyle('display', url=='' ? 'none': 'inline');
                  elem.oldUrl = url;
                }
              }
            }
          
            window.onDomReady(function() {
              for (var i = 0; i < imageNames.length; i++) {
              	var elem = $('tv' + imageNames[i]);
          		if (elem) {
          		  var url = elem.value;
          
          		  // create div and img to show thumbnail
          		  var div = new Element('div').addClass('tvimage');
          		  var img = new Element('img').setProperty('src', full_url(url)).setStyles($style);
          		  elem.getParent().adopt(div.adopt(img));
          
          		  elem.thumbnail = img;    // direct access for when need to update
          		  elem.oldUrl = url;   	   // oldUrl so change HTML only when necessary
          		  pageImages.push(elem);   // save so don't have to search each time
          		}
              }
              setInterval(checkImages, 1000);
            })
          </script>
          
          <!-- ShowImageTVs Plugin :: End -->
          EOT;
          
          	$e->output($output);
          }
          
          // ?>
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            That did the trick! My sottwell.com site is using r5053, while my local one has 5299. In which version TinyMCE isn’t loading, by the way rolleyes
              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
              • 13135
              • 30 Posts
              That made no difference, i’m on 0.9.6.3 (rev 4565)...

              Have tried versions 1.2.0.2 and 1.2.0.4 of the Image TV Preview plugin.
              Have tried the latest ManagerManager and the existing one that both work on the 0.9.6.2 (rev 4077).

              Everything else works perfectly, the only difference I can see between my site that has Image TV preview working and the sites that do not,
              is that "non-working" sites are on 0.9.6.3 (rev 4565)

              Gonna try downgrading it to 0.9.6.2 (rev 4077) to confirm the issue....
                • 7231
                • 4,205 Posts
                the edited plugin would not work in 0963- since it looks for different tags. could you be having a javascript conflict?
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 13135
                  • 30 Posts
                  Have downgraded to 0.9.6.2 and also upgraded to the latest release candidate, but still I cannot get it to work.

                  Am trying a fresh install with the latest release candidate to see if I can get it working on a base install....

                  I’m not sure what javascript could conflict with it... how can I check that out?

                  Thanks, Ian
                    • 5340
                    • 1,624 Posts
                    doesn’t work for me
                    Evolution
                    MODx version 1.0.0-RC1
                    Version codename rev 5122

                    Maybe it will be fixed in RC2
                      • 13135
                      • 30 Posts
                      I did a completely fresh install with the latest release candidate and the Image TV Preview worked.

                      I tried using the existing db from the previous site but this caused it to stop working again.

                      So I then reinstalled the blank installation database, which worked and began inputing my templates and tv’s by hand....
                      had only added 3 templates and 5 TV’s when the image preview stopped working again.
                      Have tried this with a blank template to be sure that there’s no javascript conflict in the template but no luck....

                      Really stuck on this now...