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

    I have found two snippets on the site that deal with MooFX javascript. They both will be very useful to me. The problem is, I can’t get either to work. This is my plea for help, in newbie terms. Here are the snippets...

    http://modxcms.com/forums/index.php/topic,4003.0.html
    http://modxcms.com/forums/index.php/topic,3658.0.html

    And here’s what I have done. Hopefully someone will see easily what I have done wrong and be able to guide me along the right path. I;ll start with the NeatFAQMoo, which seems to partially work.

    1) Downloaded the files moo.fx.js, moo.fx.pack.js, prototype.lite.js and placed them into,,,
    siteroot/assets/site/moofx

    2). Added the script specified on the snippet page to the default template, in the <head> and changed the path of the javascript calls to point to where they live..

    <script src="assets/site/moofx/prototype.lite.js"></script>
    <script src="assets/site/moofx/moo.fx.js"></script>
    <script src="assets/site/moofx/moo.fx.pack.js"></script>


    3). Created a new snippet called NeatFAQMoo and added the code supplied in the snippet topic , NeatFAQMoo.txt, to the new snippet.

    4). Placed [[NeatFAQMoo]] onto the page that is the FAQ Folder.

    Now here’s the thing, The FAQ’s show up, so the [[NeatFAQMoo]] snippet is, at least, finding the parent and displaying the files that reside in the folder. However, they do not react to mouseclicks and I get a javascript error

    Error: ’this.fxa[...]’ is null or not an object

    I’m lost, as I have redone this no less than ten times and can’t figure out what I am doing wrong. I did add the script..
    <script type="text/javascript">
    //Element.cleanWhitespace(’content’);
    init();
    </script>

    just before the </body> tag of the default template.

    What in the world am I doing wrong? I’m pulling my hair out on this one.

    Could anyone give me some basic instructions on how to make either one of these snippets work?
    Has anyone actually gotten them to work?

    I thank you in advance for your help.

    __________
    Banta

      • 18397
      • 3,250 Posts
      From your description it sounds like you are doing everything correct. The only thing I can suggest is trying out the moo.fx examples in your content field and seeing if they work.
        • 2759
        • 21 Posts
        I have,

        They work fine.

        It seems to me like the snippet is right but the javascript isn’t connecting.

        Is there anything to the naming convention of any of these files.  For instance, does my FAQ folder have to be named a special way, or is there some modification besides the pointers to my javascript that needs to be called?  One thing I thought was odd is that in the links for each faq rendered, there is no call to any javascript function.  Mousing over a link shows...

        javascript:;
        and the source of the rendered page shows for instance...

        <span title="#2" class="question"><a href="javascript:;"><b>Q 3 This is Question 3</b></a></span>
        <div class="stretcher">This is the answer for question 3</div>


        This is what is creating the above, from inside the snippet..

        $rest .= ’<span title="#’.$x.’" class="question"><a href="javascript:;"><b>’.$resource[$x][’pagetitle’].’</b></a></span>’."\n";

        Anything else I might try?

        Thanks for your quick reply!

        __________
        Banta
          • 2759
          • 21 Posts
          One other question I have,

          In the MooMenu snippet, Where does the code from the file  openmenu.txt  go?  It looks like this....

          $folder_to_start = 0;
          $id = $modx->documentIdentifier;
          $pid = $modx->getParent($id,1,"id");
          if($pid['id'] == $folder_to_start) {}
          while ($pid['id'] != $folder_to_start) {
              $id = $pid['id'];
              $pid = $modx->getParent($id,1,"id");
          } 
          $children2 = $modx->getDocumentChildren($folder_to_start,1,0,'id,pagetitle,hidemenu', 'hidemenu=0','menuindex ASC,pagetitle', 'ASC');   
          $childrenCount2 = count($children2);
          for($y=0; $y<$childrenCount2; $y++) {
          if ($children2[$y]['id']==$id){
          $opened = $y;}}
          if ($opened==""){
          $opened= 0;}
          echo $opened;


          Here’s the snippet again.  I couldn’t get anything to show up at all when trying this one.
          http://modxcms.com/forums/index.php/topic,4003.0.html


          ALSO, the first piece of code from the file supplied mootemplate.txt is a closing script tag....
          </script>

          Why is that?
          Thank You
            • 2759
            • 21 Posts
            Ok,

            How about someone just point me to a working example of MODx and NeatFAQMoo playing nice nice together?

            Maybe then I can try to decipher the code.

            I don’t want to give up on this just yet.

            Thank You!
              • 18397
              • 3,250 Posts
              If I had one, I’d give it to you.