We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21496
    • 225 Posts
    I was thinking about how to style the output for the active page number when pagination is active with something like [3], like we also see in the forum here. One possibility was adding $display = ’[’ . $display . ’]’; to ditto.class.php after line 1124, but then we do something evil, because we are mixing presentation with programming logic. Bad idea.

    Simpler: adding the [..] in the snippet, looking for this line of code:

    $tplPaginateCurrentPage = isset($tplPaginateCurrentPage)? $ditto->template->fetch($tplPaginateCurrentPage) : "<span class='ditto_currentpage'>[+page+]</span>";


    But then I remember I once read something about CSS, et voilà, we can achieve the same with adding those classes to our stylesheet:

    .ditto_currentpage:before {
    	content: "\5b";
    }
    
    .ditto_currentpage:after {
    	content: "\5d";
    }
    


    Note: we need the HEX Code for the content property if we use high ascii characters. "\5b" = [, "\5d" = ]

    We could also use the pipe | character, in HEX that’s "\7c"

    The only drawback ... it doesn’t work in ... yeah, you guessed it already: Internet Explorer. Not even in IE 7 sad

    I wanted to share it anyway.

    I have a question that’s related to styling the output of pagination: Is it already considered in a future release to have something like

    1 [2] 3 4 ... 7

    when we get more than 4 pages, as we see in most forums nowadays? I think that would be a nice feature.
      René
      • 18397
      • 3,250 Posts
        • 21496
        • 225 Posts
        Thanks Mark, that works. One critique, however: Under Instructions for this snippet, I find this:

        Create the snippet per the usual method, then place immediately following a Ditto call.

        Unfortunately, following the instruction doesn’t make splitPagination work. It took me one hour to figure out I have to replace the placeholder for the pagination [+pages+] with [+splitPagination+]. There is no support thread for this snippet, nor any hints in the code of the snippet. I was already about reporting it doesn’t work with Ditto 2.1b3, but was searching the forum before with splitPagination, which finally allowed me to figure it out.

        Maybe over time, people using MODx just know these things. But here I think we have an example for one of the weaknesses of MODx, the lack of documentation.

        I would appreciate if you could update the instructions with this:

        Create a new Snippet and name it SplitPagination.

        Follow the instructions to activate pagination in the Ditto documentation http://ditto.modxcms.com/tutorials/pagination.html

        Place your snippet call immeditately after the Ditto call, like in this example (modify the parameters to match your situation):

        [!Ditto?parents=`5` &display=`5` &tpl=`BlogDitto` &paginate=`1` &paginateAlwaysShowLinks=`1`!]
        [!SplitPagination!]

        Replace the placeholder [+pages+] with [+splitPages+]

        Remember, never call pagination calls cached unless the page is uncached.

        I think something like this would make everything clear and put people on the right track from the beginning.

        The Snippet SplitPagination could also be mentioned in the Ditto documentation itself.

        EDIT: I’ve just learned that &summarize is no longer necessary and replaced by &display, so I modified the example call above.



          René
          • 21496
          • 225 Posts
          Thinking about splitPagination, a question comes up: is there any disadvantage to change the line at the end of the snippet

          $modx->setPlaceholder($id."splitPages",$ph);


          into:

          $modx->setPlaceholder($id."pages",$ph);


          As far as I see, we could then really just place [!SplitPagination!] after the Ditto call, and it should work because it’s using the same placeholder [+pages+] as before.

          Or does this interfere with something I’m not aware of?
            René
            • 33337
            • 3,975 Posts
            Good idea nightsignals, lets see what Mark tells us about it.
              Zaigham R - MODX Professional | Skype | Email | Twitter

              Digging the interwebs for #MODX gems and bringing it to you. modx.link