<![CDATA[ 2.6.0 Error Logs: Could not find snippet with name . - My Forums]]> https://forums.modx.com/thread/?thread=103127 <![CDATA[2.6.0 Error Logs: Could not find snippet with name .]]> https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-555071
[2017-11-08 14:21:05] (ERROR @ /home/core/model/modx/modparser.class.php : 538) Could not find snippet with name .

I haven’t managed to pin it down to a particular manager page or action.

Any idea on tracing the snippet, whether it is me causing it, a bug or feature?]]>
ram Nov 10, 2017, 12:08 PM https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-555071
<![CDATA[Re: 2.6.0 Error Logs: Could not find snippet with name .]]> https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-560953
[[!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('.


]]>
BobRay Aug 20, 2018, 11:04 PM https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-560953
<![CDATA[Re: 2.6.0 Error Logs: Could not find snippet with name .]]> https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-560948 pyrographics Aug 20, 2018, 08:39 PM https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-560948 <![CDATA[Re: 2.6.0 Error Logs: Could not find snippet with name .]]> https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-559177
I'm working on a custom search extra that also would have found it. wink]]>
BobRay Jun 21, 2018, 10:50 PM https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-559177
<![CDATA[Re: 2.6.0 Error Logs: Could not find snippet with name .]]> https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-559172
[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.]]>
lizardx Jun 21, 2018, 04:57 PM https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-559172
<![CDATA[Re: 2.6.0 Error Logs: Could not find snippet with name .]]> https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-558917
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());




]]>
BobRay Jun 05, 2018, 05:48 AM https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name?page=2#dis-post-558917
<![CDATA[Re: 2.6.0 Error Logs: Could not find snippet with name .]]> https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name#dis-post-558916 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?]]>
sitsol Jun 05, 2018, 01:32 AM https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name#dis-post-558916
<![CDATA[Re: 2.6.0 Error Logs: Could not find snippet with name .]]> https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name#dis-post-556739
You're probably right, a dedicated snippet would probably make sense given how basic my use of it is. I guess that's one of the problems with Extras like these, they encourage laziness!
]]>
wallacio Feb 06, 2018, 09:33 AM https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name#dis-post-556739
<![CDATA[Re: 2.6.0 Error Logs: Could not find snippet with name .]]> https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name#dis-post-556727
[[#[[UltimateParent? &topLevel=`2`]].pagetitle]]


My guess is that fast-field (being a plugin that runs when the page is first loaded) is parsing the tag before UltimateParent has time to run. IIRC, FastField replaces the MODX parser. I've never trusted it for that reason. It probably could use an update.

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

FWIW, I don't use FastField and have never seen that error in the log.
]]>
BobRay Feb 05, 2018, 10:48 PM https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name#dis-post-556727
<![CDATA[Re: 2.6.0 Error Logs: Could not find snippet with name .]]> https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name#dis-post-556715
The errors I get are slightly more helpful:

/core/model/modx/modparser.class.php : 538) Could not find snippet with name #9.pagetitle.


There are many of these, with multiple resource IDs. My case is fastField related and my thinking is that it's something to do with the order or how MODX is parsing the template. I've traced it down to a Wayfinder chunk that contains the following:

<dl id="subnav"[[+wf.classes]]>
  <dt><a href="[[~[[UltimateParent? &topLevel=`2`]]]]">[[#[[UltimateParent? &topLevel=`2`]].pagetitle]]</a></dt>
  [[+wf.wrapper]]
</dl>


The error isn't triggered 100% of the time though which makes me think that when it doesn't appear, the page (or chunk) is probably being pulled from cache. In either case, the chunk appears to render correctly (I'd expect the navigation label on the page to be missing if the snippet really couldn't be found).

I'm not a fan of hiding error messages but if anyone has a clue why this could be happening, it could help others. This error message was introduced after an upgrade to 2.6.0.

/Andy]]>
wallacio Feb 05, 2018, 11:41 AM https://forums.modx.com/thread/103127/2-6-0-error-logs-could-not-find-snippet-with-name#dis-post-556715