We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6538
    • 6 Posts
    I’m looking to create a simple slider with the jQuery scrollTo and localScroll plugins. I can’t find the solution, but I’m sure I’m close to it.

    Here’s the relevant code of the working static version :
    <div id="content">
      <div id="scroller">
    
        <div class="page" id="1">
          <!-- content here -->
          <a href="#2">Read more...</a>
        </div
    
        <div class="page" id="2">
          <!-- content here -->
          <a href="#3">Read more...</a>
        </div>
    
        <!-- etc.... -->
    
      </div>  
    </div>
    


    The jQuery plugin uses the link to scroll to the right anchor.
    In Modx, I’ve created a container page (empty for now, menuId of 57). The content of the subpages are displayed in the various <div class="page">

    In the template :
      
    <div id="content">
      <div id="scroller">
        [!Ditto? &parents=`57` &display=`all` &idType=`documents` &sortBy=`id` &sortDir=`ASC` &tpl=`page-content`!]
      </div>
    </div>
    


    The chunk used by Ditto :
    <div class="page" id="[+id+]">
      <h2>[+title+]</h2>
      [+content+]
      <a href=" " title="[+title+]">Lire la suite...</a>
    </div>
    


    Everything is fine except the href attribute of the link. I can’t figure what to write there. I want to have something like "[+id+] plus 1" but can’t find the proper expression. I’ve tried the [+next+] placeholder, but it doesn’t return the value of the subpages :/ I’ve tried to put the [+id+] value in a php variable to manually add 1, but I didn’t write it right either.

    I’m really stuck. Can someone help me please ?

    Thanks ! smiley
      • 6538
      • 6 Posts
      No ideas ? undecided
        • 20413
        • 2,877 Posts
        Do you have a link to the jQuery?

        [+id+] will be replaced by the document ID
        [~[+id+]~] will output the correct url (alias if FURL turned on) to the document

        http://svn.modxcms.com/docs/display/MODx096/Document+Object
        http://ditto.modxcms.com/tutorials/creating-a-custom-template.html
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 3749
          • 24,544 Posts
          You’ll need a snippet for the href. Something like this (call it AddOne):

          <?php
          /* AddOne snippet */
          
          return '#' . $number + 1;
          
          ?>


          Then in your Tpl, put

          <a href = "[AddOne? &number=`[+id+]`]">


          I’m not sure if this will work with the parsing sequence, but it’s worth a try. I fit doesn’t, a PHX custom modifier with the same code as the snippet might work.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 8454
            • 55 Posts

            Try this:
            <a href="#[+id:math=`?+1`+]" title="[+title+]">Lire la suite...</a>

            if you have the PHx plugin (under Resources/Plugin in the manager)
            (just learned about this from member tkfm in another thread, thanks)

            You might want to put the tpl chunk in a config file and set the variable there, to get rid of a chunk, but I guess thats a matter of taste. Then:
            <?php
            
            $tpl='@CODE <div class="page" id="[+id+]">
            <h2>[+title+]</h2>
              [+content+]
              <a href="#[+id:math=`?+1`+]" title="[+title+]">Lire la suite...</a>
                </div>';
            ?>
            and save this as page-content.config.php under /snippets/ditto/configs/

            Specify the config file in the Ditto call:
            [!Ditto? &parents=`57` &display=`all` &idType=`documents` &sortBy=`id` &sortDir=`ASC` &config=`page-content`!]
              • 20413
              • 2,877 Posts
              @eddygrove That should be working even w/o having PHx plugin installed! Ditto has PHx built in. smiley

              //I don’t understand how to use the jQuery with Ditto this way though...
              Aha! --> http://modxcms.com/forums/index.php/topic,39935.msg241309.html#msg241309
                @hawproductions | http://mrhaw.com/

                Infograph: MODX Advanced Install in 7 steps:
                http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                • 6538
                • 6 Posts
                I solved it using a slightly different method. Too busy to post the solution right now, but I’ll write it soon.

                Thx for your help, everyone ! smiley
                  • 21974
                  • 20 Posts
                  Quote from: daoro at Sep 17, 2009, 03:56 AM

                  I solved it using a slightly different method. Too busy to post the solution right now, but I’ll write it soon.

                  Thx for your help, everyone ! smiley

                  any update on how you did this?
                    • 1561
                    • 22 Posts
                    Quote from: oaybar007 at Oct 22, 2009, 01:11 PM

                    Quote from: daoro at Sep 17, 2009, 03:56 AM

                    I solved it using a slightly different method. Too busy to post the solution right now, but I’ll write it soon.

                    Thx for your help, everyone ! smiley

                    any update on how you did this?


                    Up for this. What’s the update? Thanks!
                      An aspiring web designer & front-end web developer who is very much interested on the modern web.

                      www.andrewabogado.com
                      • 6538
                      • 6 Posts
                      I’m so sorry, I was so busy I forgot to come back.

                      I simpley used SerialScroll, a jQuery plugin that extends LocalScroll to do just what we need in this case.

                      It’s very simple to use, and you can find it there : http://flesler.blogspot.com/2008/02/jqueryserialscroll.html