How to add own tags using the tagify plugin, 'Mix text & tags' in particular - tags

I'm creating an input field mixed with tags and inputs using the tagify plugin- section-mix- (see: https://yaireo.github.io/tagify/#section-mix).
The problem is:
Note that tags can only be created if the value matches any of the whitelisted item's value.
I want to add them myself by hitting enter just as in the other examples in the link. Any idea how to solve this with tagify?
HTML
<textarea name='mix'>#cartman and #kyle do not know #homer who is #lisa</textarea>
JAVASCRIPT
var input = document.querySelector('[name=mix]'),
// init Tagify script on the above inputs
tagify = new Tagify(input, {
mode : 'mix', // <-- Enable mixed-content
pattern : /#/, // <-- Tag words which start with # (can be a String instead of Regex)
whitelist : [
{
value: 'Homer'
}
],
dropdown : {
enabled : 1
}
})
var whitelist_2 = ['Homer', 'Marge', 'Bart', 'Lisa', 'Maggie', 'Mr. Burns', 'Ned', 'Milhouse', 'Moe'];
// A good place to pull server suggestion list accoring to the prefix/value
tagify.on('input', function(e){
var prefix = e.detail.prefix;
if( prefix == '#' )
tagify.settings.whitelist = whitelist_2;
if( e.detail.value.length > 1 )
tagify.dropdown.show.call(tagify, e.detail.value);
}

Tagify now supports creating new tags in mix-mode as of version 3.4.0
See tagify's example page
UPDATE 24 FEB, 2020
Currently only tags without spaces can be added due to unresolved complexity in the implementation of how adding new tags in mix-mode works. I will address this soon.

Related

Typo3 Typoscript additionalHeaders header location using variable

I try to redirect a link which is coming, but before part of the link should be replaced.
tmp.getSlug = TEXT
tmp.getSlug.data = getIndpEnv : TYPO3_REQUEST_URL
tmp.getSlug.replacement {
10 {
search = myLinkPart
replace = myNewLinkPart
}
}
config.additionalHeaders.10 {
header = Location: {tmp.getSlug}
}
So from: www.myUrl.de/test/myLinkPart/test2/
To: www.myUrl.de/test/myNewLinkPart/test2/
It must be inside Typoscript because of other conditions.
Does anybody has an idea?
you are mixing different objects in a non functional way.
First you define tmp.getSlug as a typoscript object. Then you try to use it as a data variable.
Additional everything beyond tmp. is not available at rendering time. (it just is available when the typoscript is scanned.)
If you want to use the evaluation of tmp.getSlug you need to assign it to a permanent object and then store it in a register so you can access it afterwards.
Additional you need a flexible object to compose the Location header, which by default just contains a string.
Either a text object where you can use data (which must be evaluated and stored in a register before) or a COA to compose the static and the dynamic string.
This might be a solution:
tmp.getSlug = TEXT
tmp.getSlug.data = getIndpEnv : TYPO3_REQUEST_URL
tmp.getSlug.replacement {
10 {
search = myLinkPart
replace = myNewLinkPart
}
}
config.additionalHeaders.10 {
header.cObject = COA
header.cObject {
10 = TEXT
10.value = Location:
20 < tmp.getSlug
}
}

TYPO3/Typoscript : trim value failed

This is my typoscript code :
lib.test.renderObj = COA
lib.test.renderObj.10 = TEXT
lib.test.renderObj.10.stdWrap.field = header
lib.test.renderObj.10.stdWrap.case = lower
lib.test.renderObj.10.stdWrap.trim = 1
lib.test.renderObj.10.stdWrap.wrap = <div class="element">|</div>
The header field is well received, letters have been lowercased and the field is well wrapped by a element. The only problem is that i can't make the TRIM properties effective. I also tried to use the search/replace properties -> no success.
Any clue ? :)
You can search and replace since 4.6. The documentation you can find here: https://docs.typo3.org/typo3cms/TyposcriptReference/6.2/Functions/Replacement/
lib.test.renderObj.10.stdWrap.replacement {
10 {
search = # #
replace =
useRegExp = 1
}
}
Don't know if the replace is really working, can't test it.

How to overlay a cq widget so it is also available in SiteAdmin

The CQ.tagging.TagInputField provided two configuration parameter which won't work in combination:
tagsBasePath
namespaces
Using the OOTB facebook tags as example, I want to restric the dialog to only display the Favorite Teams. The Structure is this:
So I set tagBasePath to /etc/tags/facebook and namespaces to [favorite_teams]. This does what it is supposed to do and only shows the two teams in the dialog. But when you click on it, a JavaScript exceptions is thrown. The problem lies in the following method defined in /libs/cq/tagging/widgets/source/CQ.tagging.js
CQ.tagging.parseTag = function(tag, isPath) {
var tagInfo = {
namespace: null,
local: tag,
getTagID: function() {
return this.namespace + ":" + this.local;
}
};
// parse tag pattern: namespace:local
var colonPos = tag.indexOf(isPath ? '/' : ':');
if (colonPos > 0) {
// the first colon ":" delimits a namespace
// don't forget to trim the strings (in case of title paths)
tagInfo.namespace = tag.substring(0, colonPos).trim();
tagInfo.local = tag.substring(colonPos + 1).trim();
}
return tagInfo;
};
It does not respect the configurations set on the widget and returns a tagInfo where the namespace is null. I then overlayed the method in my authoring JavaScripts, but this is of course not working in the SiteAdmin as my custom JS are not included.
So, do I really have to overwrite the CQ.tagging.js below libs or can I somehow inject my overlay into the SiteAdmin so the PageProperties Dialog opened from there works as well?
UPDATE: I had a chat with Adobe support regarding this and it was pointed out that if you use tagsBasePath you need to place it somewhere else than below /etc/tags. But this won't work as well as the TagListServlet will return no tags as /etc/tags is also fixed in the TagManager as the tagsBasePath. I now overwrite the above mentioned js at its location, being well aware that I need to check it if we install a hotfix or an update. Is someone has a more elegant solution I'd be still thankful.

TYPO3: Special tt_contenttype. Modify content before output

Can I create a "special" type of tt_content, so text is beeing processed in some custom ways before outputtet?
In my case I would like to add ###MY_MARKER### somewhere in header and/or bodytext and have it replaced by the right words for the given page.
eg:
When visiting this page: mypage.com/?marker=test
Header in tt_content: "Welcome to ###MY_MARKER##, enjoy
Output in browser: "Welcome to TEST, enjoy"
I CAN do it by making a custom plugin. Question is more if I can reuse normal tt_contant for the same purpose
Yes, you can easily extend the tt_content by adding your own TCA configuration to the typo3conf/extTables.php file:
t3lib_div::loadTCA('tt_content');
$TCA['tt_content']['columns']['CType']['config']['items']['user_my_type'] = array(
0 => 'My custom content',
1 => 'user_my_type',
2 => 'i/tt_content.gif',
);
$TCA['tt_content']['ctrl']['typeicon_classes']['user_my_type'] = 'mimetypes-x-content-text';
$TCA['tt_content']['ctrl']['typeicons']['user_my_type'] = 'tt_content.gif';
/* In the following either copy, insert and modify configuration from some other
content elemenet (you can find it in the ADMIN TOOLS -> Configuration - $TCA)... */
$TCA['tt_content']['types']['user_my_type']['showitem'] = '';
/* ...or assign it some other configuration so that it's exactly the same
as some other content type and stays the same after some update of TYPO3: */
$TCA['tt_content']['types']['user_my_type']['showitem'] = $TCA['tt_content']['types']['text']['showitem'];
After that, just set in your Typoscript template how the element is supposed to be rendered:
tt_content.user_my_type = COA
tt_content.user_my_type {
10 = TEMPLATE
10 {
template = TEXT
template.field = header
marks {
MY_MARKER = TEXT
MY_MARKER.value = TEST
}
}
20 = TEMPLATE
20 {
template = TEXT
template {
field = bodytext
required = 1
parseFunc = < lib.parseFunc_RTE
}
marks < tt_content.user_my_type.10.marks
}
}
NOTES
The Typoscript rendering is just a simplified example. You might want to add other standard configuration like in other elements, e.g. the one that adds edit icons for frontend display.
The marker in my example can be populated by the value of a GET paramater in the URL as you wanted but this would have nasty security implications. You would certainly need very good validation of that input.

KRL and Yahoo Local Search

I'm trying to use Yahoo Local Search in a Kynetx Application.
ruleset avogadro {
meta {
name "yahoo-local-ruleset"
description "use results from Yahoo local search"
author "randall bohn"
key yahoo_local "get-your-own-key"
}
dispatch { domain "example.com"}
global {
datasource local:XML <- "http://local.yahooapis.com/LocalSearchService/V3/localsearch";
}
rule add_list {
select when pageview ".*" setting ()
pre {
ds = datasource:local("?appid=#{keys:yahoo_local()}&query=pizza&zip=#{zip}&results=5");
rs = ds.pick("$..Result");
}
append("body","<ul id='my_list'></ul>");
always {
set ent:pizza rs;
}
}
rule add_results {
select when pageview ".*" setting ()
foreach ent:pizza setting pizza
pre {
title = pizza.pick("$..Title");
}
append("#my_list", "<li>#{title}</li>");
}
}
The list I wind up with is
. [object Object]
and 'title' has
{'$t' => 'Pizza Shop 1'}
I can't figure out how to get just the title. It looks like the 'text content' from the original XML file turns into {'$t' => 'text content'} and the '$t' give problems to pick().
When XML datasources and datasets get converted into JSON, the text value within an XML node gets assigned to $t. You can pick the text of the title by changing your pick statement in the pre block to
title = pizza.pick("$..Title.$t");
Try that and see if that solves your problem.
Side notes on things not related to your question to consider:
1) Thank you for sharing the entire ruleset, what problem you were seeing and what you expected. Made answering your question much easier.
2) The ruleset identifier should not be changed from what AppBuilder or the command-line gem generate for you. Your identifier that is currently
ruleset avogadro {
should look something more like
ruleset a60x304 {
3) You don't need the
setting ()
in the select statement unless you have a capture group in your regular expression
Turns out that pick("$..Title.$t") does work. It looks funny but it works. Less funny than a clown hat I guess.
name = pizza.pick("$..Title.$t");
city = pizza.pick("$..City.$t");
phone = pizza.pick("$..Phone.$t");
list_item = "<li>#{name}/#{city} #{phone}</li>"
Wish I had some pizza right now!