We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40395
    • 67 Posts
    Quote from: BobRay at Jul 06, 2012, 10:53 AM
    Just noticed a formatting problem in this line. You're missing the quotation mark after href=:


    Instead of

    echo($qparastart."<a href=[~71~]\"#".$faq[$row][$IDindex]."\">".$faq[$row][$qindex]."</a></p>");


    I think you want this:

    echo($qparastart."<a href=\"[~71~]\"#".$faq[$row][$IDindex]."\">".$faq[$row][$qindex]."</a></p>");



    Thanks for the revision. I tried it but the anchor element of the URL is not returned. The url stops after the page name. I tried as many variations as I could but no joy.

    It sounds like I'm using snippets incorrectly any way so I'll have to try and form the faq page in a different way. Shame as it's almost there smiley
      • 3749
      • 24,544 Posts
      Try using $output = instead of echo. Then put this at the end of the snippet:

      return $output;



      I know that what you're trying should work. I do it often.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 2 months ago.]
        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
        • 3749
        • 24,544 Posts
        I ran this in my editor (pasting your line of code):

        $row = 1;
        $IDindex = 1;
        $qindex = 2;
        
        $faq[$row][$IDindex] = 'StringOne';
        $faq[$row][$qindex] = 'StringTwo';
        $qparastart = '<p>';
        
        echo ($qparastart."<a href=\"[~71~]\"#".$faq[$row][$IDindex]."\">".$faq[$row][$qindex]."</a></p>");


        It echos this:

        <p><a href="[~71~]"#StringOne">StringTwo</a></p><p><a href="[~71~]"#StringOne">StringTwo</a></p>


        So there's nothing wrong with your code. Maybe one of your strings has a quote, apostrophe, or some illegal character in it. Or maybe you have magic_quotes_gpc turned on. (Though you really should use $output rather than echo).



        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          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
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          There's still an extra " in there; that should be
          <a href="[~71~]#StringOne">
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 3749
            • 24,544 Posts
            Good eye Susan. It should be:

            echo ($qparastart."<a href=\"[~71~]#".$faq[$row][$IDindex]."\">".$faq[$row][$qindex]."</a></p>");


            Which produces:

            <p><a href="[~71~]#StringOne">StringTwo</a></p>



            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html
              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
              • 40395
              • 67 Posts
              Susan, Bob thanks so much for your help, that did the trick perfectly smiley

              I've not tried outputting from the snippet to a string for display yet but so far so good.

              Thanks again. 8-)

                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Quote from: alchemy at Jul 06, 2012, 10:49 AM
                Quote from: Everettg_99 at Jul 06, 2012, 10:07 AM

                Today's cunning plan was to just drop the raw php into the page template but it looks like the page templates only support html sad

                As you can tell I need to understand how all this hangs together a little better !

                http://sottwell.com/modx-from-the-inside.html
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 40395
                  • 67 Posts
                  Thanks everyone for your help. The final result is here:

                  http://www.3d-alchemy.co.uk/3d-printing-faqs.html

                  It didn't help that I spent half a day trying to work out why the CSS wasn't being applied to the top section of questions until I realised that they were links /rolls eyes/ !