We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30734
    • 44 Posts
    Bruno
    It looks like it was going to work but when the link is selected i get a blank page. The URL appears to be coming across correctly.

    /index.php?id=2&objectID=1


    I changed the tpl (i was going to do that later anyways) to see if that would have any affect and it did not. Here is the current migxLoopCollection call as well as the tpl chunk.

    [[!migxLoopCollection?
      &packageName=`sriagenda`
      &classname=`sriagenda_spk`
      &tpl=`tpl_speaker_bios`
      &where=`{"id":"[[!getReqParam? &name=`objectID`]]"}`
    ]]


    [[+spk_fname]] [[+spk_lname]]
      • 4172
      • 5,888 Posts
      does

      [[!getReqParam? &name=`objectID`]]


      return anything?

      did you install the getReqParam - snippet?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 30734
        • 44 Posts
        ugh... i had downloaded but not installed it. Thanks so much Bruno!
          • 30734
          • 44 Posts
          Another quick question. I am setting up the tabbed navigation for the agenda page and I only want each day to show up once ( Nov 9, Nov 10, Nov 11) I believe I read somewhere about the &groupby command would do this for me. Only problem is since the times are different for the sessions the ses_start is different for each one. Is there a way to get the &groupby to only look at %Y-%m-%e?
            • 4172
            • 5,888 Posts
            for the outer migxLoopCollection (which builds the tabs)
            you can try:

            &groupby=`DATE(ses_start)`


            you will need inner migxLoopCollection - calls to get the sessions for each date
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 30734
              • 44 Posts
              That worked for creating the tabs perfectly. Like you said I am also adding the inner migxLoopCollection calls for each date. However I can't seem to get the &where calls to work correctly. The closest I have gotten is:

              &where=`{"ses_start":"[[+ses_start]]"}`


              This is only displaying 1 session per day. How do I adjust this to output all of the sessions for the day?
                • 30734
                • 44 Posts
                I was just wondering if anyone would have some insights for me with my last issue. I have been working on it and combing through other forum posts, but I have not been able to come up with an answer. I still seem to only be able to get my inner migxLoopCollection to display either 1 post for each day, or all of the posts for all of the days under each tab. I can't seem to get it to output each session just once and only under the tab for its day. Any help would be appreciated.

                Agenda Template
                <h3>[[+conf_theme]]</h3>
                [[+conf_start:strtotime:date=`%B %e`]] - [[+conf_end:strtotime:date=`%e %Y`]]
                <br/><br/>
                <ul class="nav nav-tabs" role="tablist">
                [[!migxLoopCollection?
                &packageName=`sriagenda`
                &classname=`sriagenda_ses`
                &groupby=`DATE(ses_start)`
                &tpl=`migxLC_tpl_datetabs`
                ]]
                </ul>
                
                <div class="tab-content">
                  [[!migxLoopCollection?
                &packageName=`sriagenda`
                &classname=`sriagenda_ses`
                &groupby=`DATE(ses_start)`
                &tpl=`migxLC_tpl_sestabs`
                ]]
                </div>
                


                sestabs template
                <div class="tab-pane" id="[[+ses_start:strtotime:date=`%Y-%m-%d`]]">
                <br/>
                <h2>[[+ses_start:strtotime:date=`%A, %B %e, %Y`]]</h2>
                <br/>
                [[!migxLoopCollection?
                &packageName=`sriagenda`
                &classname=`sriagenda_ses`
                &where=`{"ses_start":"[[+ses_start]]"}`
                &tpl=`migxLC_tpl_sessm`
                &limit=`0`
                ]]
                </div>
                
                  • 4172
                  • 5,888 Posts
                  you can try:

                  &where=`{
                    "ses_start:>=":"[[+ses_start:strtotime:date=`%Y-%m-%d 00:00:00`]]",
                    "ses_start:<=":"[[+ses_start:strtotime:date=`%Y-%m-%d 23:59:59`]]"
                  }`


                  but added the DATE - function to the where-property
                  change the migxLoopCollection - snippet - code to (will be included with the next version of MIGX)

                  <?php
                  
                  $tpl = $modx->getOption('tpl', $scriptProperties, '');
                  $wrapperTpl = $modx->getOption('wrapperTpl', $scriptProperties, '');
                  $limit = $modx->getOption('limit', $scriptProperties, '0');
                  $offset = $modx->getOption('offset', $scriptProperties, 0);
                  $totalVar = $modx->getOption('totalVar', $scriptProperties, 'total');
                  
                  $where = $modx->getOption('where', $scriptProperties, '');
                  $where = !empty($where) ? $modx->fromJSON($where) : array();
                  $queries = $modx->getOption('queries', $scriptProperties, '');
                  $queries = !empty($queries) ? $modx->fromJSON($queries) : array();
                  $sortConfig = $modx->getOption('sortConfig', $scriptProperties, '');
                  $sortConfig = !empty($sortConfig) ? $modx->fromJSON($sortConfig) : array();
                  $configs = $modx->getOption('configs', $scriptProperties, '');
                  $configs = explode(',', $configs);
                  $toSeparatePlaceholders = $modx->getOption('toSeparatePlaceholders', $scriptProperties, false);
                  $toPlaceholder = $modx->getOption('toPlaceholder', $scriptProperties, false);
                  $outputSeparator = $modx->getOption('outputSeparator', $scriptProperties, '');
                  //$placeholdersKeyField = $modx->getOption('placeholdersKeyField', $scriptProperties, 'MIGX_id');
                  $placeholdersKeyField = $modx->getOption('placeholdersKeyField', $scriptProperties, 'id');
                  $toJsonPlaceholder = $modx->getOption('toJsonPlaceholder', $scriptProperties, false);
                  $jsonVarKey = $modx->getOption('jsonVarKey', $scriptProperties, 'migx_outputvalue');
                  $prefix = isset($scriptProperties['prefix']) ? $scriptProperties['prefix'] : null;
                  
                  $packageName = $modx->getOption('packageName', $scriptProperties, ''); 
                  $joins = $modx->getOption('joins', $scriptProperties, '');
                  $joins = !empty($joins) ? $modx->fromJson($joins) : false;
                  
                  $selectfields = $modx->getOption('selectfields', $scriptProperties, '');
                  $selectfields = !empty($selectfields) ? explode(',', $selectfields) : null;
                  
                  $addfields = $modx->getOption('addfields', $scriptProperties, '');
                  $addfields = !empty($addfields) ? explode(',', $addfields) : null;
                  
                  $debug = $modx->getOption('debug', $scriptProperties, false);
                  
                  $packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
                  $modelpath = $packagepath . 'model/';
                  
                  $modx->addPackage($packageName, $modelpath, $prefix);
                  $classname = $scriptProperties['classname'];
                  
                  $base_path = $modx->getOption('base_path', null, MODX_BASE_PATH);
                  $base_url = $modx->getOption('base_url', null, MODX_BASE_URL);
                  
                  $migx = $modx->getService('migx', 'Migx', $modx->getOption('migx.core_path', null, $modx->getOption('core_path') . 'components/migx/') . 'model/migx/', $scriptProperties);
                  if (!($migx instanceof Migx))
                      return '';
                  //$modx->migx = &$migx;
                  $defaultcontext = 'web';
                  $migx->working_context = isset($modx->resource) ? $modx->resource->get('context_key') : $defaultcontext;
                  
                  $properties = array();
                  foreach ($scriptProperties as $property => $value) {
                      $properties['property.' . $property] = $value;
                  }
                  
                  $idx = 0;
                  $output = array();
                  $c = $modx->newQuery($classname);
                  $c->select($modx->getSelectColumns($classname, $classname, '', $selectfields));
                  
                  if ($joins) {
                      $migx->prepareJoins($classname, $joins, $c);
                  }
                  
                  if (!empty($where)) {
                      foreach ($where as $key=>$value){
                          if (strstr($key,'MONTH') || strstr($key,'YEAR') || strstr($key,'DATE')){
                              $c->where($key . " = " . $value, xPDOQuery::SQL_AND);
                              unset($where[$key]);
                          }
                      }
                      $c->where($where);
                  }
                  
                  if (!empty($queries)) {
                      foreach ($queries as $key => $query) {
                          $c->where($query, $key);
                      }
                  
                  }
                  
                  if (!empty($groupby)) {
                      $c->groupby($groupby);
                  }
                  
                  //set "total" placeholder for getPage
                  $total = $modx->getCount($classname, $c);
                  $modx->setPlaceholder($totalVar, $total);
                  
                  if (is_array($sortConfig)) {
                      foreach ($sortConfig as $sort) {
                          $sortby = $sort['sortby'];
                          $sortdir = isset($sort['sortdir']) ? $sort['sortdir'] : 'ASC';
                          $c->sortby($sortby, $sortdir);
                      }
                  }
                  
                  //&limit, &offset
                  if (!empty($limit)) {
                      $c->limit($limit, $offset);
                  }
                  
                  if ($debug){
                    $c->prepare();echo $c->toSql();
                  }
                  
                  $template = array();
                  
                  if ($collection = $modx->getCollection($classname, $c)) {
                      foreach ($collection as $object) {
                          $fields = $object->toArray('', false, true);
                          
                          if (!empty($addfields)){
                              foreach ($addfields as $addfield){
                                  $addfield = explode(':',$addfield);
                                  $addname = $addfield[0];
                                  $adddefault = isset($addfield[1]) ? $addfield[1] : '';
                                  $fields[$addname] = $adddefault; 
                              }
                          }
                          
                          if ($toJsonPlaceholder) {
                              $output[] = $fields;
                          } else {
                              $fields['_alt'] = $idx % 2;
                              $idx++;
                              $fields['_first'] = $idx == 1 ? true : '';
                              $fields['_last'] = $idx == $limit ? true : '';
                              $fields['idx'] = $idx;
                              $rowtpl = '';
                              //get changing tpls from field
                              if (substr($tpl, 0, 7) == "@FIELD:") {
                                  $tplField = substr($tpl, 7);
                                  $rowtpl = $fields[$tplField];
                              }
                  
                              if ($fields['_first'] && !empty($tplFirst)) {
                                  $rowtpl = $tplFirst;
                              }
                              if ($fields['_last'] && empty($rowtpl) && !empty($tplLast)) {
                                  $rowtpl = $tplLast;
                              }
                              $tplidx = 'tpl_' . $idx;
                              if (empty($rowtpl) && !empty($$tplidx)) {
                                  $rowtpl = $$tplidx;
                              }
                              if ($idx > 1 && empty($rowtpl)) {
                                  $divisors = $migx->getDivisors($idx);
                                  if (!empty($divisors)) {
                                      foreach ($divisors as $divisor) {
                                          $tplnth = 'tpl_n' . $divisor;
                                          if (!empty($$tplnth)) {
                                              $rowtpl = $$tplnth;
                                              if (!empty($rowtpl)) {
                                                  break;
                                              }
                                          }
                                      }
                                  }
                              }
                  
                              $fields = array_merge($fields, $properties);
                  
                              if (!empty($rowtpl)) {
                                  $template = $migx->getTemplate($tpl, $template);
                                  $fields['_tpl'] = $template[$tpl];
                              } else {
                                  $rowtpl = $tpl;
                  
                              }
                              $template = $migx->getTemplate($rowtpl, $template);
                  
                  
                              if ($template[$rowtpl]) {
                                  $chunk = $modx->newObject('modChunk');
                                  $chunk->setCacheable(false);
                                  $chunk->setContent($template[$rowtpl]);
                  
                  
                                  if (!empty($placeholdersKeyField) && isset($fields[$placeholdersKeyField])) {
                                      $output[$fields[$placeholdersKeyField]] = $chunk->process($fields);
                                  } else {
                                      $output[] = $chunk->process($fields);
                                  }
                              } else {
                                  if (!empty($placeholdersKeyField)) {
                                      $output[$fields[$placeholdersKeyField]] = '<pre>' . print_r($fields, 1) . '</pre>';
                                  } else {
                                      $output[] = '<pre>' . print_r($fields, 1) . '</pre>';
                                  }
                              }
                          }
                  
                  
                      }
                  }
                  
                  if ($toJsonPlaceholder) {
                      $modx->setPlaceholder($toJsonPlaceholder, $modx->toJson($output));
                      return '';
                  }
                  
                  if (!empty($toSeparatePlaceholders)) {
                      $modx->toPlaceholders($output, $toSeparatePlaceholders);
                      return '';
                  }
                  
                  if (is_array($output)) {
                      $o = implode($outputSeparator, $output);
                  } else {
                      $o = $output;
                  }
                  
                  if (!empty($o) && !empty($wrapperTpl)) {
                      $template = $migx->getTemplate($wrapperTpl);
                      if ($template[$wrapperTpl]) {
                          $chunk = $modx->newObject('modChunk');
                          $chunk->setCacheable(false);
                          $chunk->setContent($template[$wrapperTpl]);
                          $properties['output'] = $o;
                          $o = $chunk->process($properties);
                      }
                  }
                  
                  if (!empty($toPlaceholder)) {
                      $modx->setPlaceholder($toPlaceholder, $o);
                      return '';
                  }
                  
                  return $o;
                  


                  I think, this should work then:

                  &where=`{"DATE(ses_start)":"[[+ses_start:strtotime:date=`%Y-%m-%d`]]"}`
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 30734
                    • 44 Posts
                    Hello!
                    After working with the system I must say it is amazing, Thank you so much for your help Bruno! I have one small thing I need help figuring out which is sorting the speakers by their name instead of their ID in the session speaker selection. I currently recoded it to look like this in the input value:

                    @EVAL return 'Select Speaker==||' . $modx->runSnippet('migxLoopCollection',array('packageName'=>'sriagenda','classname'=>'sriagenda_spk','tpl'=>'@CODE:[[+spk_fname]] [[+spk_lname]]==[[+id]]','outputSeparator'=>'||','sortby'=>'spk_fname','sortdir'=>'ASC'));


                    That doesn't seem to do anything.
                      • 4172
                      • 5,888 Posts
                      there is a sortConfig-property, which you can use to sort by multiple fields.
                      try:
                      @EVAL return 'Select Speaker==||' . $modx->runSnippet('migxLoopCollection',array('packageName'=>'sriagenda','classname'=>'sriagenda_spk','tpl'=>'@CODE:[[+spk_fname]] [[+spk_lname]]==[[+id]]','outputSeparator'=>'||','sortConfig'=>'[{"sortby":"spk_fname","sortdir":"ASC"}]'));


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

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!