We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10355
    • 44 Posts
    How to call data from a custom table and in order to have SEF URLs?
      • 4172
      • 5,888 Posts
      see how it is done in gallery.
      there is a plugin for onPageNotFound, which handles FURLs for the gallery-table.

      here is another (bit stripped down) example I made for different custom-tables and different contexts these days
      for links with /section/year/month/day/alias.
      As base I used that from gallery.

      <?php
          function onPageNotFound(){
              $pageid['news_id_web']='553';
              $pageid['events_id_web']='615';
      
              //$corePath=$this->modx->getOption('newsandmore.core_path',null,$this->modx->getOption('core_path').'components/newsandmore/');
              $xdbshowPath=$this->modx->getOption('xdbshow.core_path',null,$this->modx->getOption('core_path').'components/xdbshow/');
      
              /* handle redirects */
              $search = $_SERVER['REQUEST_URI'];
              $base_url = $this->modx->getOption('base_url');
              if ($base_url != '/') {
                  $search = str_replace($base_url,'',$search);
              }
              $search = trim($search, '/');
      
              /* figure out archiving */
              $params = explode('/', $search);
      
              if ($params[0]<>'news' && $params[0]<>'events') return false;
      
              //get the news section from Furl    
              $prefix='';
              $section=$params[0];
              $_REQUEST[$prefix.'year'] = $params[1];
              if (isset($params[2])) $_REQUEST[$prefix.'month'] = $params[2];
              if (isset($params[3])) $_REQUEST[$prefix.'day'] = $params[3];
              if (isset($params[4])) $_REQUEST[$prefix.'alias'] = $params[4];
              
              $_REQUEST['section']=$section;
              switch ($section){
                  case 'news':
                      $classname = 'News';
                  break;
                  case 'events':
                      $classname = 'Events';
                  break;
                  default:
                  return false;
              }
      
              // check if requested object exists
              $req_id='';
              $configs['classname']=$classname;
              //$getnews = $this->modx->getService('getnews','Getnews',$this->modx->getOption('core_path').'components/newsandmore/model/newsandmore/',$configs);
              $xdbshow = $this->modx->getService('xdbshow','Xdbshow',$xdbshowPath.'model/');
              $xdbshow->checkPublishStatus($classname);
              $this->config['classname']=$classname;
      		$count = $this->getpage($_REQUEST,$req_id,false);
              if($count<1){
                  return false;
              }
      
              /* forward */
              $this->modx->sendForward($pageid[$section.'_id_'.$this->modx->context->get('key')]);
              return false;	
          }
      ?>

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

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!