We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17073
    • 4 Posts
    I have very very limited PHP knowledge. I am using the PrevJumpNext snippet, I have used the output <div> and <span> to create CSS background images for the Next and Previous buttons.
    I would like to <div> or <span> the ’Previous’ and ’Next’ text to allow me to hide the text and so just the image is clickable.

    i.e. I would like to do something like this (if it were possible):-
    # Text to use with the link "Prev" when $displayTitle is set to false
    if(!isset($prevText)){
    $prevText=<div class="hideprev">"Prev"<div>;

    and then in css
    .hideprev{display:none;}

    Does anyone have any suggestions to get round this?

    Many thanks!
      • 27708 MODX Staff
      • 2,502 Posts
      It isn’t a perfect solution but you could try:

      .hide{
          text-indent:-10000px;
      }
      

      and then
      if(!isset($prevText)){
      $prevText=<div class="hide">"Prev"<div>;
      


      This will work to move the text off screen. I have never used this snippet so I can’t say for sure if this will work.

      Let me know...

      Jay
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 13912
        • 7 Posts
        Thanks Jay,

        I think their problem is that by moving the text, the links go with it!?

        First of all take a look at the following link which is how it currently works - and how it should work from a usability point of view:

        http://85.234.152.247/lgwww/index.php?id=5

        Now here is the test page with prevnext snippet version:

        http://85.234.152.247/lgwww/index.php?id=49

        Basically, the first link does actually work, it’s just a bit of a messy implementation. All the content goes in one document, and there is some javascript which pages between divs. It’s difficult to add / edit content this way.

        With the second link - and the prevnext test - you can see the snippet forces the prev/next links to be text and there doesn’t seem to be a way to change these text links to image links... so they can be used as forward / back arrows...

        Hope that clarifies...
          • 27708 MODX Staff
          • 2,502 Posts
          They mentioned using a background image.

          If you have a defined container size with a width and height and the position of the div is constant, text-indent will not move the image. If you are using a foreground image (that is on the text plane) it will move.

          Now since I have looked at this I think that the issues lie within the JS and not in the snippet. The Js is outputting the styles and therefore overriding any sheet rules.

          Time to start digging. smiley
            Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
            • 13912
            • 7 Posts
            I’m certainly no expert at this, but I can’t see any JS on that test link apart from the quickedit stuff.

            Perhaps some example code of how to use prevnext with images rather than text would help them?

              • 17073
              • 4 Posts
              Thank you for your help Jay!
              It would be good if we could check that this is the correct way adding a css class selector to php code?

              # Text to use with the link "Prev" when $displayTitle is set to false
              if(!isset($prevText)){

              $prevText=<div class="hideprev">"Prev"</div>;

              Many thanks!
                • 27708 MODX Staff
                • 2,502 Posts
                @lgltd. That is a good question. It is not this will result in the breaking of your output. There is not any need to change the snippet to add a class to achieve what you want. Just use .PJN_Menu a to select the links and make the text-indent a really big negative number. If you feel that you must add a class or id then you should do it at the bottom where the snippet sets the placeholders at around line 255.

                Again you already have a parent class so to grab elements beneath you use the cascade to select an element that qualifies.

                .PJN_Menu a{
                    background: ...
                    display:block;
                    width:100px;
                    height:100px;
                    text-indent:-10000px;
                }
                .PJN_Next a{...}
                .PJN_Prev a{...}
                


                That is all the rules you need to set. extra classes are unnecessary.

                @jeffrhysjones

                Sorry, I was confused as I was doing two things at once.

                Now that I am paying attention.

                I don’t have time to give you the whole deal but here is how it should be done.

                First: The background should be set on the PJN_Next a and PJN_Prev a and not on the spans. Second, you need to make your PJN_Menu a elements block elements that are the same size as their container or define the width and height. Third by adding the images as the backgrounds of the a elements and using text-indent: -10000px you should get what you want.

                See the big onrange link on this page as an example of how it can be done:

                http://www.kneadedbodywork.com/

                It uses the exact same principal.

                Looking at the CSS files though it looks as though some problems may arise from the cascade since some things are all out of order.

                Let me know if you need some small help.

                Cheers,

                Jay


                  Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
                  • 17073
                  • 4 Posts
                  Many many thanks Jay for spelling it out!!
                  I think the main problem was that I didn’t have a set width for .PJN_Menu and I hadn’t used the ’a’ link in the CSS (ie .PJN_Next{..} instead of PJN_Next a{...}).