We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20865
    • 30 Posts
    Haven’t read the topic, but if you want to have a next-prev page work on a childrens - getPage won’t work.
    This is the code of my pagination, it is grabbing (right)ID(&rid = `[[*id]]`) to form link and pageTitle.
    $temp= $modx->db->query("Select id, pagetitle, template From `modx_site_content` WHERE template=5");
    while($row = $modx->db->getRow($temp))
    {
      if($row['id'] == $rid)
      {
        $row = $modx->db->getRow($temp); 
        $pt2 = $row['pagetitle'];
        if(isset($pt2)){$pt2 .= ">>";}
        $rid2 = $row['id']; 
        break;
      }
      $pt1 = "<<".$row['pagetitle'];
      $rid1 = $row['id'];
    }
    $rid1 = "[[~".$rid1."]]";
    $rid2 = "[[~".$rid2."]]";
    $modx->setPlaceholder('PageTitle1',$pt1);
    $modx->setPlaceholder('fid',$rid1);
    $modx->setPlaceholder('PageTitle2',$pt2);
    $modx->setPlaceholder('sid',$rid2); // first id, second id
    $output = $modx->parseChunk('news_content_page', $modx->placeholders);
    return $output;​

    PS it would be interesting to see other people solutions on the same problem and check the results )
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      It may be noteworthy to mention the version you’re developing that on. That snippet looks like it’s for Evolution (or if it’s Revolution - you should definitely update it as the DBAPI is going to be removed in the upcoming 2.1 release wink

      I think Xantulle is developing something for Revolution.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 20865
        • 30 Posts
        It was developed for Revo(MODx Revolution 2.0.5-pl (traditional))
        I’m actually a newbe in modx and this is my first experience.
        I don’t know much(especially about DBAPI, but I’m learning) so I just use the knoweledge I have to solve the problems.
        And it would be interesting to see anouther solution for this problem, just for experience and compare the efficency of each script.
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          The DBAPI ($modx->db->...) was something heavily used in Evolution, and it was included in Revolution to provide easier migration from Evolution to Revolution, however in 2.1 (which should be the next release) it wont be available anymore, so your script will then break.

          xPDO or MODX Objects aren’t that hard to learn. For example, these are the first two linen of your code:
          $temp= $modx->db->query("Select id, pagetitle, template From `modx_site_content` WHERE template=5");
          while($row = $modx->db->getRow($temp)) { ... }


          In Revolution you would do this slightly differently:
          $c = $modx->newQuery('modResource');
          $c->where(array(
            'template' => 5));
          $result = $modx->getCollection('modResource',$c);
          foreach ($result as $row) {
            ...
          }

          Within the foreach, $row is an object which gives you access to all fields needed.

          For example $row->get(’pagetitle’), but you could also do $row->getOne(’template’)->get(’name’) and much, much more. You could look on the rtfm for more information on xPDO.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 20865
            • 30 Posts
            I can make it work on just MySQL, like mysq_fetch_array($query).
            It is a question of speed of the query and ease of use.
            Classes in PHP for me are completely new, and I haven’t got used to use them(sorry for my bad english, there can be unclear moments).
            But I have understood that this classes can work MUCH faster than original PHP functions, so it is usefull thing. But if I don’t know how to make it work with existing functions - I will make it work on just PHP guaranteed. It can be bulky, slow and unsafe but it will work.
              • 18373 ☆ A M B ☆
              • 3,141 Posts
              You’re free to use MySQL statements... but to be future proof it may be better to use xPDO/MODX statements. The abstraction (MODX figures out what the table name is, and how the fields are called) allows the database structure to me modified while keeping the rest update-safe.
                Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                • 20865
                • 30 Posts
                I’m not a pro, I’m just learning )
                And I don’t know xPDO or DBAPI at all. But I’m trying to use those functions, but I If haven’t seen required functions in rtfm and if I do not see ready solutions - I’m starting topics like "Login.Login and IPB". Often nobody reply’s and crutches with raw-programming appear in my code )
                  • 9102 ☆ A M B ☆
                  • 318 Posts
                  The getPage module produces links with: ?page=number

                  How can I get this to change to just the number, like ’www.mydomain.com/projects/1’ for page 1.

                  I wrote a post a while ago on this topic. My technique includes a way to have a unique title and description for each page.

                  http://modxcms.com/forums/index.php/topic,56621.0.html