What would be the best and/or simplest way to remove an element from a XML document using anti-xml?
Here is one way:
(xml \ "nodeToRemove").filter { _.name != "nodeToRemove"}.unselect.head
Any others?
Not sure whether this is better or not, but you could use the drop method, like so:
(xml \\ 'nodeToRemove drop 1).unselect.head
which assumes a single occurrence of nodeToRemove; you can drop all items in the resulting Zipper if there is more than one occurrence.
Also, as the drop complements, the take and slice methods remove anything that's not included in their ranges.
Related
This question already has an answer here:
Karate UI: How to click a specific checkbox with same class name
(1 answer)
Closed 1 year ago.
I am stuck with a case where the need is to click on an icon after asserting inputs from the user. In case there were some unique identifiers, the thing was pretty simple like the use of: rightOf('{}UniqueIdentifier').find('i').click() served the purpose.
Also working fine with: scroll('{}UniqueIdentifier').parent.children[4].click()
But in case the table contains repeated values nothing could be found unique to search for and click. For which the thought was to match entire row text where the last element is that icon which needs to be clicked OR any other method which suits this?
Table looks like this:-
Need to click on triple dot icon for- A2,P2,2,resolved. How can this be achieved using wildcard locators? I tried creating a list of elements and match it with user input list but failed doing so.
Any help would be appreciated. Thanks!
First you should get comfortable with locateAll(). It will return an array of Element objects. And after that there are many possible ways of looping over and finding what you want.
Also note that there is a "locateAll() with filter": https://github.com/intuit/karate/tree/master/karate-core#locateall-with-filter
Since you haven't provided any HTML I will have to guess. And note that x below is an Element and you can even call locate() on it.
* def filter = function(x){ x.text.contains('Unique Identifier') }
* def list = locateAll('.grand-parent-class', filter)
* list[0].parent.children[4].click()
TYPO3 has the function TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes() to add or replace one or more fields to the BE form of a record.
How can we remove fields?
(replacing by '' does not work)
Explanation:
Its about hiding some fields in tt_content for some CTypes only.
In the past we did it by overwriting the complete value. But with the upgrade from 6.2LTS to 8LTS we run into problems as the default labels have changed (pathes to the language files) and so some labels become lost in the BE, which was noticed very late.
Now I want a clean way to remove single fields so that the definition of the remaining fields stays clean with the default values from core (or other extensions).
Other extensiosn which add their own fields also are a problem if the value is set with a static string: these fields are also removed.
Since there is indeed no way to insert an empty string, you could create an empty palette instead. This way you will still get a non empty string to insert, but it will not create any output in the form.
addToAllTCAtypes('table', '--palette--;;empty', '', 'replace:fieldname')
And you should make a feature request, to make at least the replacement with an empty string possible in upcoming versions of TYPO3.
Do it in the code like this:
foreach ($GLOBALS['TCA']['yourtablenamehere']['types'] as &$definition) {
$definition['showitems'] = '';
}
if you only need to reset a specific type ('0', for example):
$GLOBALS['TCA']['yourtablenamehere']['types']['0']['showitems'] = '';
If you want to override types completely instead of clearing them (clearing only does not much sense anyway):
$GLOBALS['TCA']['yourtablenamehere']['types']['0']['showitems'] = 'title, bodytext';
I would like to create a "cleanup" extension that replaces various characters (quotes by guillemets) in all kinds of textfields in TYPO3.
I thought about extending <f:format.html> or parseFunc, but I don't know where to "plug in" so I get to replace output content easily before it's cached.
Any ideas, can you give me an example?
If you don't mind regexing, try this:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['cleanUpQuotes'][] = \NAMESPACE\Your\Extension::class;
Insert it into ext_localconf.php and this part is done.
The next step is the class itself:
public function cleanUpQuotes(TypoScriptFrontendController $parentObject)
{
$parentObject->content = DO_YOUR_THING_HERE
}
There also is another possibility which could replace any strings in the whole page - as it operates on the rendered page (and not only on single fields).
You even can use regular expressions.
Look at my answer -> here
$GLOBALS['TCA']['tt_content']['types'][$myCType]['columnsOverrides']['imagecols']['config']['items'] = [[2,2],[3,3]];
But above not working it just replace fist two items with my list but other items are still visible how can i override items array for my custom ctype?
It seems, \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(), which is used to handle the columnsOverrides, does allow unsetting a key (or array), but not replacing a substructure.
Maybe it's possible to find a combination of unsetting and afterwards merging with new values.
In this case you can use TCEFORM to solve your task.
TCEFORM.tt_content.imagecols.types.myCType.keepItems = 2,3
I am stumped beyond belief.
I have a select box being generated by the cakephp form helper. I am feeding it an array of options, and passing an empty value... pretty standard stuff.
However, my "empty" field is showing up at the very bottom of the list.. not the top. So when the field loads, it just defaults to the first option... which is not the "empty" option.
Not a whole lot of room for error on the code here..
echo $this->Form->input('whatever',array('empty'=>'Choose One','options'=>$categories));
The only small item that might be important, is that $categories is a multi-array, so the select box has optgroups & options.
Is there some quirk/bug out there that I do not know of that is trying to force me to sneak into my scotch supply a few hours ahead of schedule?
edit: using the latest release of cakephp 1.3.x
I think that I once had the same problem.
It turned out to be the data (options array).
Is there an option with an empty key? probably the last one then.
this lead to the scenario I remember and seems to be the exact same thing.
the form helper will override this empty key value pair then and not create a second one.
without more infos from your end this will be difficult to solve.