I have an odd problem, which has only come up with the latest version of MODx.
I posted here (
http://forums.modx.com/thread/69810/auto-tag-tv-type-in-newspublisher?page=2) about a solution I had for using autoTag TVs with NewsPublisher and jquery ui to create a list by which the user could populate a NP field. At the time, this worked beautifully, but recently needed to update MODx to 2.2.14. Since then, a bug has been created that has been difficult to isolate. Let me go through the error first.
You'll see in the forum post I previously mentioned that I have followed the steps originally outlined, and have even posted my own version of the chunk, which still looks like this:
<div id="np-[[+npx.fieldName]]-container" class="np-text">
[[+np.error_[[+npx.fieldName]]]]
<label class="fieldlabel" for="np-[[+npx.fieldName]]" [[+npx.readonly]] title="[[+npx.help]]">[[+npx.caption]]: </label>
<input name="[[+npx.fieldName]]" class="text" id="np-[[+npx.fieldName]]" type="text" value="[[+np.[[+npx.fieldName]]]]" maxlength="[[+npx.maxlength]]" />
</div>
<script>
$(function() {
var [[+npx.fieldName]]Tags = [ [[!tagLister? &tv=`[[+npx.fieldName]]` &tpl=`npTagTplJSON` &parents=`213` &sortBy=`tag` &limit=`0` &outputSeparator=`,`]] ];
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
$( "#np-[[+npx.fieldName]]" )
// don't navigate away from the field on tab when selecting an item
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
$( this ).data( "ui-autocomplete" ).menu.active ) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0,
source: function( request, response ) {
// delegate back to autocomplete, but extract the last term
response( $.ui.autocomplete.filter(
[[+npx.fieldName]]Tags, extractLast( request.term ) ) );
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( ", " );
return false;
}
});
});
</script>
The error shows in tagLister snippet call - the npx.fieldName placeholder isn't parsing before the snippet is called.
If...
[[+npx.fieldName]] = performers
... then this call fails to produce a result:
[[!tagLister? &tv=`[[+npx.fieldName]]` &tpl=`npTagTplJSON` &parents=`213` &sortBy=`tag` &limit=`0` &outputSeparator=`,`]]
...but this call works successfully, :
[[!tagLister? &tv=`performers` &tpl=`npTagTplJSON` &parents=`213` &sortBy=`tag` &limit=`0` &outputSeparator=`,`]]
I think the problem is in NewsPublisher itself; it's no longer accounting for the placeholder nested in the tagLister snippet call, because tagLister is being parsed before NewPublisher deals with its own placeholders in the chunk.
So I need a solution here - can anyone help me work out how to make this work?