We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29597 ☆ A M B ☆
    • 350 Posts
    I got the GitHUB version...

    Will do a fresh reinstall and try again!

    Tried..... And failed >:(

    Still the same, it seems to work but no extra fields for the images....
      MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
      DESIGNfromWITHIN, MPThemes and Any Screen Size
      Follow me on Twitter | Read my blog | My code on GitHub
      • 436 ☆ A M B ☆
      • 265 Posts
      An idea I’ve had for a while is some kind of Image Layout TV - I tried creating this using MIGX this evening and was wondering if something is possible, or could be implemented.

      Basically when a client adds an image they get some simple layout options, like this:



      Depending on what they choose their image is either left-aligned in the article, centered, right-aligned or the full article width - this part of the idea could be achieved with the IF snippet inside the getImage template.

      Then ideally the client would be able to add a placeholder to the article where they’d like each image to appear e.g. [[+image-01]]; then they could add a second, third, fourth image, etc and add them using the placeholders.

      At the moment with MIGX the template output has to be in one location, which is good for a slideshow or carousel, but I can’t think of a way to make it work when the output is broken up in the main [[*content]] area?

      If this isn’t already somehow possible, perhaps something like a &toSeparatePlaceholders property could be added like the getResources snippet has?
        MODX Ambassador for Thailand. Managing Director at Monogon, a web design and development studio based in Bangkok, Thailand. - Follow me on Twitter.
        • 4172
        • 5,888 Posts
        &toSeparatePlaceholders and toPlaceholder added to the latest github-version.

        Please use the MIGX - Thread for new comments.
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 23018
          • 353 Posts
          Hi there.

          I’m a HAPPY user of this plugin. I believe it is a great addition to MODx.

          Yesterday I upgraded to revo 2.1 and now I have an unexpected problem that MIGHT be related to MIGX. Is anyone here that has an idea whats wrong here?


          I’m using the following plugins/extensions in this example:

          [[getUrlParam]] To safely grab a parameter from the current URL (https://gist.github.com/809938)
          [[If]] To check if the parameter meets certain criteria (http://rtfm.modx.com/display/ADDON/If)
          [[getImageList]] To grab the content from one or more lines of a multicolumnsgrid (a.k.a MIXG - http://rtfm.modx.com/display/addon/MIGX)

          The following codeblock worked prior upgrading from 2.0.8 to 2.1

          	[[!If?
          	&subject=`[[!getUrlParam? &name=`details` &int=`1` ]]`
          	&operator=`gte`
          	&operand=`0`
                  &debug=`1`
          	&then=`<!-- then -->
          		[[getImageList? 
          			&tvname=`Details`
          			&tpl=`Bildarchiv Kunstobjekte_single - tpl`
          			&limit=`1`
          			&offset=`[[!getUrlParam:subtract=`1`? &name=`details` &int=`1` ]]`
          		]]
          	`
          	&else=`<!-- else -->
          		[[getImageList? 
          			&tvname=`Details` 
          			&tpl=`Bildarchiv Kunstobjekte_all - tpl`
          		]]`? 
          	`
          	]]
          


          Before I upgraded to revo2.1 I got the expected results. Either a particular line of the grid or all of them. Now I only get one of the comments I added to the code to find out what’s happening.

          From my point of view [[If]] and [[getURLParam]] work as expected so I THINK that it might be related to MIGX.


          I really appreciate any advice on this.

          Regards,

          pepebe
            Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
            • 4172
            • 5,888 Posts
            can’t see what can be wrong here. This should work as it did before.

            Perhaps a cache-issue?
            Did you move your tv-properties to input-properties?
            MIGX-TVs at backend are still working?
            TV-image-pathes are configured correctly?
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 23018
              • 353 Posts
              Quote from: Bruno17 at Jun 02, 2011, 02:11 PM

              can’t see what can be wrong here. This should work as it did before.

              Perhaps a cache-issue?
              Did you move your tv-properties to input-properties?
              MIGX-TVs at backend are still working?
              TV-image-pathes are configured correctly?


              Edit: Problem was solved. See below.

              Hi Bruno17.

              Thanks for your fast response.

              Regarding your advice:

              • No, caching doesn’t seem to be the problem
              • Yeah I moved them.
              • MIGx TVs show up and can be edited
              • The images also show up.

              There might be an issue with an older version of multiitemsGridTV. I deleted multitemsTV from core/components, are there more files to get rid off?

              Regards,

              pepebe


              Update: If I move

              		[[getImageList? 
              			&tvname=`Details` 
              			&tpl=`Bildarchiv Kunstobjekte_all - tpl`
              		]]
              


              outside the [[If]] block it works as expected. So it should be a problem with MIGx working from within the [[If]] plugin.

              Another update:

              Just realized that [[If]] is behaving in a very strange way as soon as MOGx is inside then=`` or else=``.

              Example:
              	&then=`
              		[[getImageList? 
              			&tvname=`Details`
              			&tpl=`Bildarchiv Kunstobjekte_single - tpl`
              			&limit=`1`
                                      &offset=`[[!getUrlParam:subtract=`1`? &name=`details` &int=`1` ]]`
              		]]
              <li>details=[[!getUrlParam? &name=`details` &int=`1` ]]</li>
              	`


              Results in nothing.
              .
              	&then=`
              <li>details=[[!getUrlParam? &name=`details` &int=`1` ]]</li>	`
              


              Returns details=x as expected.

              It seems that usage of [[getImageList]] within [[If]] finishes the whole statement and prevents any output. This is getting weird...

              (Final) update:

              I realized that the whole problem comes down to part of the tpl I used.

                        [[+Details:notempty=`
                              <a href="[[~[[*id]]? &details=`0`]]" title="">
                                 [[returnContext:is=`de`:then=`Weitere Abbildungen`:else=`further images`]]
                              </a><br />
                        `]]
              


              The culprit is the [[+Details:notempty=`...` conditional. If I remove the conditional part everything works as expected. I’m sure it worked earlier but I might be wrong about that. If I’m wrong please don’t be mad with me for wasting your time. If I’m right, I really would like to know what happened here.

              To get the original results, I changed that part:
                        [[getImageList:notempty=`
                              <a href="[[~[[*id]]? &details=`0`]]" title="">
                                 [[returnContext:is=`de`:then=`weitere Abbildungen`:else=`further images`]]
                              </a><br />
                        `? &tvname=`Details` &limit=`1`
                        ]]
              


              So, that’s it.

              Thanks for your patience,

              pepebe


              Update: @bruno17 Should I move this a new thread?
                Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
                • 23018
                • 353 Posts
                BTW: I don’t know if there is an easier way to do that, but I frankensteined a snippet returning the number of rows inside a MIGx Grid.

                Regards,

                pepebe

                Snippet: countGridlines
                <?php
                /**
                 * countGridlines snippet by pepebe
                 * 
                 * Paramters:
                 * tvname: Name of MOGx TV (required)
                 * docid: Defaults to the current document. Use this one to check a Grid from another document (optional)
                 * 
                 * Usage: 
                 * [[countGridlines:gt=`0`:then=`dothis`:else=`dothat`? 
                 *       &tvname=`images` 
                 *       &docid=`123` 
                 * ]]
                 **/
                
                $tvname = $modx->getOption('tvname', $scriptProperties, '');
                $docid = $modx->getOption('docid', $scriptProperties, $modx->resource->get('id'));
                
                if (!empty($tvname)) {
                    if ($tv = $modx->getObject('modTemplateVar', array('name' => $tvname))) {
                        $outputvalue = $tv->renderOutput($docid);
                    }
                }
                
                if (empty($outputvalue)) {
                    return '0';
                }
                
                $items = count($modx->fromJSON($outputvalue));
                
                return $items;
                
                  Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
                  • 29597 ☆ A M B ☆
                  • 350 Posts
                  Hi I am trying to create a packaged theme that use MIGX,

                  Everything seems to be working Packing and installing chunks, snippets, TV’s, template files and other packages and my project is coming a long nicely.

                  I do still have one small issue:

                  I use MIGX to create slides for a jQuery slider.
                  To get it to work I need a TV called multiItemsGrid and under Input options need to add:

                  Form Tabs:
                  [
                  {"caption":"Info", "fields": [
                      {"field":"title","caption":"Title","description":"Title for the image."},
                      {"field":"description","caption":"Description","inputTV":"richtext"},
                  	{"field":"slide_option","caption":"Slide type","inputTV":"slide_option"}
                  ]},
                  {"caption":"Image", "fields":[
                      {"field":"image","caption":"Image","inputTV":"image"}
                  ]}
                  ] 


                  Grid Columns:
                  [
                  {"header": "Title", "width": "160", "sortable": "true", "dataIndex": "title"},
                  {"header": "Image", "width": "50", "sortable": "false", "dataIndex": "image","renderer": "this.renderImage"}
                  ]


                  Now my question is how do I add this code with a Build Script?

                  I use this and the MIGX TV is added and the input settings is migx, but the form and grid settings are not added.

                  $tvs[2]= $modx->newObject('modTemplateVar');
                  $tvs[2]->fromArray(array(
                      'id' => 2,
                      'name' => 'multiItemsGrid',
                      'caption' => 'Slider items',
                      'description' => 'The items in the slider',
                      'category' => 'MODULAR',
                      'type' => 'migx',
                      'display' => 'default',
                      'locked' => 0,
                      'rank' => 0,
                      'default_text' => '',
                      'display_params' => '',
                      'formtabs2' => '
                  [
                  {"caption":"Info", "fields": [
                      {"field":"title","caption":"Title","description":"Title for the image."},
                      {"field":"description","caption":"Description","inputTV":"richtext"},
                      {"field":"slide_option","caption":"Slide type","inputTV":"slide_option"}
                  ]},
                  {"caption":"Image", "fields":[
                      {"field":"image","caption":"Image","inputTV":"image"}
                  ]}
                  ]
                  	',
                      'columns2' => '
                  [
                  {"header": "Title", "width": "160", "sortable": "true", "dataIndex": "title"},
                  {"header": "Image", "width": "50", "sortable": "false", "dataIndex": "image","renderer": "this.renderImage"}
                  ]
                  	',
                  ),'',true,true);


                  Any help?
                  B.t.w. This Build Script thing is very cool! Thinking about many projects with it!
                    MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
                    DESIGNfromWITHIN, MPThemes and Any Screen Size
                    Follow me on Twitter | Read my blog | My code on GitHub
                    • 4172
                    • 5,888 Posts
                    I’m not sure, but I think you should use something like that:

                    <?php
                    
                    
                    $input_properties=array(
                        'formtabs' => '
                    [
                    {"caption":"Info", "fields": [
                        {"field":"title","caption":"Title","description":"Title for the image."},
                        {"field":"description","caption":"Description","inputTV":"richtext"},
                        {"field":"slide_option","caption":"Slide type","inputTV":"slide_option"}
                    ]},
                    {"caption":"Image", "fields":[
                        {"field":"image","caption":"Image","inputTV":"image"}
                    ]}
                    ]
                    	',
                        'columns' => '
                    [
                    {"header": "Title", "width": "160", "sortable": "true", "dataIndex": "title"},
                    {"header": "Image", "width": "50", "sortable": "false", "dataIndex": "image","renderer": "this.renderImage"}
                    ]
                    ');
                    $tv->set('input_properties',$input_properties);
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 22826
                      • 9 Posts
                      This is a fantastic addition to MODx and a must have. We have been using MIGx for territory specific page translations and also for filtering output by one of the input fields e.g. output the contact numbers for simplified chinese

                      I thought I would share what we have done and see if it is useful to further enhance an already excellent addon. The following snippets of code are based on the MIGx addon and are geared towards translations of a single Document Resource.

                      For the filtering of the results, we created a "getFilteredList" snippet based on the "getImageList" snippet, the code is as follows:

                      <?php
                      // [[!getFilteredList? &tvname=`t_metaContent` &tpl=`chunkName` &docid=`[[+id]]` &filterBy=`tcode` &filterValue=`ar` ]]
                      
                      $tvname = $modx->getOption('tvname', $scriptProperties,'');
                      $tpl = $modx->getOption('tpl', $scriptProperties, '');
                      $docid = $modx->getOption('docid', $scriptProperties,$modx->resource->get('id'));
                      $limit = $modx->getOption('limit', $scriptProperties, '0');
                      $offset = $modx->getOption('offset', $scriptProperties, 0);
                      $filterBy = $modx->getOption('filterBy', $scriptProperties, ''); // Name of the field to filter by
                      $filterValue = $modx->getOption('filterValue', $scriptProperties, ''); // The value of the filterBy field
                      $debug = $modx->getOption('debug', $scriptProperties, '');
                      
                      $displayLang = isset($_SESSION['session_lang_display_setting']) ? $_SESSION['session_lang_display_setting'] : 'en'; // get the custom language session code 
                      
                      $hasTCode = false;
                      
                      if (empty($tpl)) return 'empty property: &tpl';
                      
                      if (!empty($tvname)) {
                      	if ($tv = $modx->getObject('modTemplateVar', array('name' => $tvname))) {
                      		$outputvalue = $tv->renderOutput($docid);
                      		/*
                      		*   get inputTvs 
                      		*/
                      		$properties = $tv->get('input_properties');
                      		$properties = isset($properties['columns']) ? $properties : $tv->getProperties();
                      		$formtabs = $modx->fromJSON($properties['formtabs']);
                      		$inputTvs = array();
                      		if (is_array($formtabs)) {
                      			foreach ($formtabs as $tab) {
                      				if (isset($tab['fields'])) {
                      					foreach ($tab['fields'] as $field) {
                      						if (isset($field['inputTV'])) {
                      							$inputTvs[$field['field']] = $field['inputTV'];
                      						}
                      					}
                       				}
                      			}
                      		}
                      	}
                      }
                      
                      if (empty($outputvalue)) return '';
                      
                      $tempItems = $modx->fromJSON($outputvalue);
                      $items = array();
                      
                      if(!empty($filterBy) && !empty($filterValue)){
                      	
                      	foreach($tempItems as $item)
                      	{
                      		if($item[$filterBy] == $displayLang)
                      		{
                      			array_push($items,$item);
                      		}
                      	}
                      }
                      else
                      {
                      	$items = $tempItems;
                      } 
                      //$items = $modx->fromJSON($outputvalue);
                      
                      
                      $limit = $limit == 0 ? count($items) : $limit;
                      $output = '';
                      if (substr($tpl, 0, 6) == "@FILE:") 
                      {
                          $template = file_get_contents($modx->config['base_path'] . substr($tpl, 6));
                      } 
                      else
                      {
                      	if (substr($tpl, 0, 6) == "@CODE:") 
                      	{
                      		$template = substr($tpl, 6);
                      	} 
                      	else
                      	{
                      		if ($chunk = $modx->getObject('modChunk', array('name' => $tpl), true)) 
                      		{
                      			$template = $chunk->getContent();
                      		} 
                      		else 
                      		{
                      			$template = false;
                      		}
                      
                      		if ($template) 
                      		{
                      			if (count($items) > 0) 
                      			{
                      				$idx = 0;
                      				
                      				foreach ($items as $key => $item) 
                      				{
                      					$fields = array();
                      					
                      					foreach ($item as $field => $value) 
                      					{
                      					
                      						if (isset($inputTvs[$field])) 
                      						{
                      							if ($tv = $modx->getObject('modTemplateVar', array('name' => $inputTvs[$field]))) 
                      							{
                      								$tv->set('default_text', $value);
                      								$fields[$field] = $tv->renderOutput($docid);
                      							}
                      						} 
                      						else 
                      						{
                      							$fields[$field] = $value;
                      						}
                      					}
                      					
                      					$doFilter = ( !empty($filterBy) && !empty($filterValue) ) ? true : false;
                      					$addToList = ( $item[$filterBy] == $displayLang ) ? true  : false;
                      					
                      					if ($key >= $offset && $idx < $limit) 
                      					{
                      						$fields['_alt'] = $idx % 2;
                      						$idx++;
                      						$fields['_first'] = $idx == 1 ? true:'';
                      						$fields['_last'] = $idx == $limit ? true:'';
                      						$fields['idx'] = $idx;
                      						$chunk = $modx->newObject('modChunk');
                      						$chunk->setCacheable(false);
                      						$chunk->setContent($template);
                      						$output .= $chunk->process($fields);    
                      					}
                      				}
                      			}
                      		}
                      	}
                      }
                      
                      $modx->setPlaceholder($totalVar, count($items));
                      
                      return $output;
                      


                      The next snippet, "getLanguageItem", uses a MIGx TV called "t_metaContent" that has fields named exactly as the common fields e.g. content, pagetitle, longtitle etc an example of the "Input Options" for "Form Tabs" below:

                      [
                      	{"caption":"Meta Data", "fields": 
                      		[
                      			{"field":"code","caption":"Select the language:","inputTV":"t_code"},
                      			{"field":"pagetitle","caption":"Title:","description":"The translated title of the page"}, 
                      			{"field":"longtitle","caption":"Long Title:","description":"The translated long title of the page"}, 
                      			{"field":"content","caption":"Main Content:","inputTV":"t_content"}
                      		]
                      	}
                      ]
                      
                      


                      The "t_metaContent" looks like the below:



                      The "getLanguageItem" snippet does use 2 non MODx sessions called "session_lang_display_setting" and "session_site_lang_context" to determine the context and the required language, and brings back the content of the field based on the language code:

                      <?php
                      // [[!getLanguageItem? &tvname=`t_metaContent` &field=`pagetitle` &docid=`[[+id]]` ]]
                      
                      $tvname = $modx->getOption('tvname', $scriptProperties,'');
                      $docid = $modx->getOption('docid', $scriptProperties,$modx->resource->get('id'));
                      $field = $modx->getOption('field', $scriptProperties,'');
                      $processTvs = $modx->getOption('processTvs', $scriptProperties, '');
                      $tCode = $modx->getOption('tCode', $scriptProperties, 'code'); // Translation field by default it is called code
                      $justUseDataFromTv = $modx->getOption('justUseDataFromTv', $scriptProperties, ''); //
                      $debug = $modx->getOption('debug', $scriptProperties, '');
                      
                      $output = "";
                      $hasTCode = false;
                      $isSymlink = false;
                      
                      if(empty($field)) return;
                      
                      // Check to see if there is the possibilty of content being translated
                      $showTranslation = ( isset($_SESSION['session_lang_display_setting']) && $_SESSION['session_lang_display_setting'] != 'en' && $_SESSION['session_site_lang_context'] != 'web' ) ? true : false;
                      
                      // Get the Session language to display (default is en)
                      $displayLang = (isset($_SESSION['session_lang_display_setting']) ) ? $_SESSION['session_lang_display_setting'] : 'en';
                      
                      try
                      {
                      	// Get the resources for the page
                      	$resource = $modx->getObject('modResource', $docid);
                      
                      	// If we need to check meta content and other TV's, else don't bother
                      	if(empty($justUseDataFromTv))
                      	{
                      		// Check and see if we are dealing with a symlink
                      		if(is_numeric($resource->get('content'))) $isSymlink = true;
                      
                      		// If the translation field is NOT a template variable check that the language IS English
                      		if(empty($processTvs))
                      		{
                      			if($isSymlink)
                      			{
                      				$symlinkId = $modx->runSnippet('getSymlinkId', array('pageid'=>$docid));
                      				// Got to Catch whether the SymlinkId is the same the document ID: would be bad form from the inputter
                      				if($symlinkId == $docid) return 'ERROR: Symlinking to itself. Check Symlink ID in the resource.';
                      				
                      				$resource = $modx->getObject('modResource', $symlinkId);
                      				// Got to check whether the resource coming back is a symlink: again Bad form!!!
                      				if($resource->get('class_key') == 'modSymLink') return 'ERROR: Symlinking to a Symlink Resource. Check Symlink ID in the resource';
                      			}
                      	
                      			$output = $resource->get($field);
                      		}
                      		else
                      		{
                      			// check to see if there is a TV by the name of the required field
                      			$tv = $modx->getObject('modTemplateVar', array('name' => $field));
                      			if($tv != null)
                      			{
                      				$output = $tv->renderOutput($docid);
                      			}
                      		}
                      
                      		// No need to go further if there is no translation checking to be done.
                      		if(!$showTranslation) return $output;
                      	}
                      
                      	// OK standard fields don't apply from now on.
                      
                      	if(!empty($tvname))
                      	{
                      		if($tv = $modx->getObject('modTemplateVar', array('name' => $tvname)))
                      		{
                      			$outputvalue = $tv->renderOutput($docid);
                      		
                      			$properties = $tv->get('input_properties');
                      			$properties = isset($properties['columns']) ? $properties : $tv->getProperties();
                      			$formtabs = $modx->fromJSON($properties['formtabs']);
                      			$inputTvs = array();
                      			$inputFields = array();
                      		
                      			if (is_array($formtabs)) 
                      			{
                      				foreach ($formtabs as $tab) 
                      				{
                      					if (isset($tab['fields'])) 
                      					{
                      						foreach ($tab['fields'] as $f) 
                      						{
                      							$inputFields[$f['field']] = $f['field'];
                      							if (isset($f['inputTV'])) 
                      							{
                      								$inputTvs[$f['field']] = $f['inputTV'];
                      							}
                      						}
                      					}
                      				}
                      			}
                      		}
                      	}
                      
                      	if(empty($outputvalue)) return $output;
                      
                      	// There is an output value to work with.
                      	$items = $modx->fromJSON($outputvalue);
                      
                      	// Next thing to check is whether there is a language code field to check against
                      	if(array_key_exists($tCode,$inputFields))
                      	{	
                      		// Create a language array with the items array
                      		$translationArray = array();
                      		foreach($items as $item)
                      		{
                      			if(count($item) > 0)
                      			{
                      				foreach($item as $f => $value)
                      				{
                      					if (isset($inputTvs[$f])) 
                      					{
                      						if ($tv = $modx->getObject('modTemplateVar', array('name' => $inputTvs[$f]))) 
                      						{
                      							$tv->set('default_text', $value);
                      							$translationArray[$item[$tCode]][$f] = $tv->renderOutput($docid);
                      						}
                      					}
                      					else
                      					{
                      						$translationArray[$item[$tCode]][$f] = $value;
                      					}
                      				}
                      			}
                      		}
                      	
                      		if(!empty($debug)) var_dump($translationArray);
                      	
                      		if(count($translationArray) > 0)
                      		{
                      			$transOutput =  $translationArray[$displayLang][$field];
                      		
                      			if(!empty($transOutput)) 
                      			{
                      				$output = $transOutput;
                      			}
                      		}
                      	}
                      }catch (Exception $e) {
                      	$output = $e->getMessage();
                      }
                      
                      return $output;
                      


                      There is another snippet used in the "getLanguageItem" snippet called "getSymlinkId" which has the following code

                      <?php
                      if(empty($pageid))
                      {
                      	$id = $modx->resource->get('id');
                      }
                      else
                      {
                      	$id = $pageid;
                      }
                      $c = $modx->newQuery('modResource');
                      $c->select('content');
                      $c->where(array('id'=>$id));
                      $c->prepare();
                      $c->stmt->execute();
                      $symlinkId = $c->stmt->fetchColumn();
                      $c->stmt->closeCursor();
                      
                      if(is_numeric($symlinkId) && !empty($symlinkId))
                      {
                      	return intval($symlinkId);
                      }
                      



                      Hopefully these 3 snippets based on MIGx are useful.


                      Again brilliant work on MIGx Bruno.