Hey,
I also wanted to list the available tags as toggle buttons underneath the textfield and found a quick way to achieve this. It does however depend on the tagLister Extra so you need to install that first.
Then in core/components/newspublisher/model/newspublisher/newspublisher.class.php around line 858 add this:
case 'autotag':
$formTpl .= $this->_displaySimple($name, 'TagOuterTpl', '');
break;
Note that the template name 'TagOuterTpl' does not include the prefix 'np'.
Back in the manager you create a chunk called 'npTagOuterTpl' with this code:
<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>
[[!tagLister? &tv=`tags` &tpl=`npTagTpl` &parents=`1` &limit=`100`]]
<script>
function toggleTag(t){
var val = document.getElementById("np-[[+npx.fieldName]]").value;
var tags = val ? val.split(',') : [];
var index = tags.indexOf(t);
if(index > -1){
tags.splice(index, 1);
}else{
tags.push(t);
}
document.getElementById("np-[[+npx.fieldName]]").value = tags.join(',');
}
</script>
And then another chunk called 'npTagTpl':
<button class="toggleTag" type="button" name="toggleTag-[[+tag]]" onclick="toggleTag('[[+tag]]')">[[+tag]]</button>
I think that was it. I haven't tested it extensively yet but it seems to work...
Edit: I just realised that since the tagLister snippet is for front-end use it only lists tags of published resources .. had me puzzled for a while
[ed. note: vacatoro last edited this post 10 years, 4 months ago.]