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

    This is probably documented somewhere, but I’ve missed it. I totally get how to use getPage/getResources to break a listing of resources into multiple pages, but I haven’t been able to figure out how to break a *single* resource (ie. a long blog post) into multiple pages.

    It’s really not an urgent deal, but I have a couple of posts that would probably be a little easier to follow if they were broken into multiple pages.

    Any pointers would be greatly appreciated.

    Thanks!

    Swill
      • 20358
      • 10 Posts
      It’s possible I may have asked the wrong question here too. I guess I assumed that getPage would be the tool for this job, but maybe it isn’t. So, perhaps before asking my original question, I should ask the following:

      Is it *possible* to break a single resources into multiple pages using getPage?

      I’m thinking of something like the "next page" tag in Word Press, which gives you something like ?id=X?page=Y in the URL. I’ve never bothered to look at the code, so I’m not sure exactly it works.

      Again, totally non-urgent, just curious if it’s doable. In fact, the more I think about it, the more I see a much more general debate under the hood of all this. What’s really more user friendly, a long blog post where a user has to continue scrolling, or a long blog post with a bunch of page links? Hmm...

      Swill
        • 17723
        • 221 Posts
        Hi,
        I’m looking to find a way to paginate a page content with getPage too, but no results.
        Could someone advice us on the way we should go huh
        Luke

          Lucas from AroundCyprus.net
          • 4172
          • 5,888 Posts
          you can try this:

          use this snippet, which breaks the content into parts delimited by '{BREAK}' and outputs an json-string.


          <?php
          //[[!splitContentToJson]]
          $delimiter = $modx->getOption('delimiter',$scriptProperties,'{BREAK}');
          
          $content = $modx->getOption('content',$scriptProperties,$modx->resource->getContent());
          $contents = explode($delimiter,$content); 
          if (count($contents)>0){
              foreach ($contents as $content){
                  $output[]['content']=$content;
              }
          return $modx->toJson($output);
          }


          then you can use this json-string in getImageList from MIGX-TV like that:

          [[!getImageList? &value=`[[splitContentToJson]]`&tpl=`@CODE:[[+content]]` ]]


          and its possible to use getImageList together with getPage the same way as you would do it with getResources.

          [[!getPage? 
          &element=`getImageList` 
          &value=`[[!splitContentToJson]]`
          &tpl=`@CODE:[[+content]]`
          &limit=`1`
          ]]
          <div class="pageNav">[[!+page.nav]]</div>





          [ed. note: Bruno17 last edited this post 12 years, 7 months ago.]
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!