We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43864
    • 151 Posts
    Quote from: BobRay at Feb 05, 2018, 10:48 PM


    Replacing the FastField stuff with a dedicated snippet might solve it, since you'd have more control over when it runs.


    I also use fastfield a lot as I have been told it's a fast plugin, faster then f.e. resourcefield. I think it's from the same guys of pdotools, but I can be wrong.

    What would you recommend in place Bob?
      • 3749
      • 24,544 Posts
      Maybe FastField will be updated to work with newer versions of MODX. I don't think it would be a difficult conversion. It think FF could also could be redfactored as a plugin connected to OnParseDocument.

      A custom snippet that gets a single field would be fairly fast if you don't need TVs. If you do need TVs, I'd suggest moving the data somewhere else (system settings or the DB).

      These are both untested. Let me know if they work.

      This would be a very fast way to get a resource field:

      [[!getResourceField? &id=`12` &field=`introtext`]]


      /* getResourceField snippet */
      $query = $modx->newQuery('modResource', $id);
      $query->select('introtext');
      return $modx->getValue($query->prepare());
      


      This would be very fast with TV values, but it assumes that you can use the raw value of the TV and that no TV you want the value of is set to its default value:

      [[!tvValue? $resource=`12` $tv=`22`]]


      /* tvValue snippet */
      $query = $modx->newQuery('modTemplateVarResource', array('contentid` => $resource, 'tmplvarid' => $tv));
      $query->select('value');
      return $modx->getValue($query->prepare());




        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
        • 17284
        • 54 Posts
        In the process of cleaning up our error logs, I also came across this:
        [2018-06-20 00:26:16] (ERROR @ /.../modx-core/model/modx/modparser.class.php : 538) Could not find snippet with name 290.


        Fastfield is not installed. I'm wondering if maybe it's related to a deleted snippet, but it's just guesswork. I set the log_snippet_not_found warning setting to No just to get rid of it in the logs, though I don't like hiding warnings because sometimes they show relevant things you should be aware of.

        No snippet name was attached to the number 290, and, also interesting, when I checked our snippet ID numbers, none of them are above 100.

        I don't know when this issue started because I hadn't checked our logs for a while.

        I decided to actually figure this out rather than masking the issue, which turned out to be real, I'll outline the process I used, which only will work if you have access to your physical raw server web-logs.

        1. go to your server web log directory. Ours are separated into gz'ed daily files, which are date stamped in the file name, which makes it easier. You are searching for the time stamp you saw in the modx error logs:
        zgrep '00:26:16' site20180620.gz

        repeat for all missing snippet errors. This will give you the page(s) url. If you get nothing, try adding or subtracting one second from the time stamp, sometimes logs get written right at the switch to a new second.

        2. go to the page in the resource editor, search for the snippet id number if you don't see any non existing snippets in the code. In our case, it turned out to be a bad office admin updater who had sloppily copied and pasted:
        <a href="[[290]]">


        You'll note that without the ~ in the link shortcut [[~290]] it becomes a snippet call, thus tripping the missing snippet error.

        Repeat until you've found all instances. So in this case, this had nothing to do with snippets, it was just bad site updaters being sloppy, and adding in a nothing link, which is then processed as a snippet which does not exist, which then trips modx error reporter, absolutely correctly.

        Since such a sloppy link error is very easy to make, and very hard to spot, this method will let you find all the pages without having to go through them one by one, which is obviously not possible once you have more than a handful of pages. [ed. note: lizardx last edited this post 5 years, 9 months ago.]
          • 3749
          • 24,544 Posts
          Good catch. I think using egrep -r on the cache directory searching for \[\[\d+] might also have worked.

          I'm working on a custom search extra that also would have found it. wink
            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
          • I am experiencing this same issue using pdoTools code...ie [[#8.mytv]] with MODX output filters such as [[#8.mytv:notempty=`<img src="[[#8.mytv]]">`]]. Not sure why except maybe there is an order of execution issue.
              • 3749
              • 24,544 Posts
              You could try replacing that with a snippet called getTV:

              [[!getTV? &resourceId=`8` $tvId=`12`]]


              /* getTV snippet */
              
              $fields = array(
                  'tmplvarid' => $tvId,  /* TV ID */
                  'contentid' => $resourceId,  /* Resource ID */
              );
               
              $tvr = $modx->getObject('modTemplateVarResource', $fields);
              if ($tvr) {
                  $tvValue = $tvr->get('value');
              } else {
                  /* getObject() failed -- get the default value of the TV */
                  $tv = $modx->getObject('modTemplateVar', 12);
                  $tvValue = $tv->get('default_text');
              }
              
              return empty($tvValue)? '' : $tvValue;
              


              In the code above, you can leave out the "else" clause if no TV is ever set to the TV's default value.

              This will be *much* faster than the output modifier (which is actually getting the TV value twice), though it requires that you use the ID of the TV rather than its name.

              If you need to use the name, you could do this, which is still much faster than the output modifier:

              [[!getTV? &resourceId=`8` $tvName=`mytv`]]


              /* getTV snippet */
              $tv = $modx->getObject('modTemplateVar', array('name => $tvName));
              $value = $tv->getValue($resourceId);
              return empty($value)? '' : $value;
              


              Both versions assume that you want to return nothing if the TV value is empty (the '' part of the last line of the snippets). If not put something else between the quotes.

              They also assume that you can use the raw (unprocessed) value of the TV. If you need the TV to be processed (you don't if it's just a path to the image), use the second version and replace 'getValue(' with 'renderOutput('.


                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