I'm fairly new to typoscript and the manual (which I tried to read) isn't that helpful.
I have the following typoscript:
30 = TEXT
30 {
typolink {
parameter = 1079
returnLast = url
}
wrap (
<li class="mod-metanav--item">
<a class="mod-metanav--link" href="|">
Help
</a>
</li>
)
}
Now, the word «Help» needs to be translated.
I found out that I can use something like this to translate text in TS
5 = TEXT
5.data = LLL:fileadmin/content/translation.xml:help
5.wrap(
<li class="mod-metanav--item">
<span style="font-size: 10px; color: #777;">|</span>
</li>
)
But, I need to kind of double-wrap the text (5) into the link (30) and that's where I fail.
I found some documentation on wrap2/wrap3 and innerWrap/outerWrap, but there aren't any examples that match my case and I can't adapt the examples I find to my case...
The first part (30) was made by someone else and I have the suspicion that there's another way to achieve this...
Any hints?
For all who run into the same problem - here's what I came up with:
30 = TEXT
30 {
typolink {
parameter = 1079
returnLast = url
}
wrap (
<a class="mod-metanav--link" href="|">
)
prepend = COA
prepend{
10 = TEXT
10.value = <li class="mod-metanav--item">
}
append = COA
append{
10 = TEXT
10.data = LLL:fileadmin/content/translation.txt:hilfe
10.wrap(
|
</a>
</li>
)
}
}
The trick is to pre-/append the additional parts.
Still it feels like an ugly hack and I'm sure I'm supposed to put the HTML-part into the template.
Related
I have a textarea id="task", which has a word counter id="count" connected. The counter is set to count spaces between words, so a word is only accounted for if one puts a space after it. However, if for whatever reason one finds themself in a frenzy of hitting the spacebar, each and every space is then counted as a word which thwarts the final count. Below is the code for you to see for yourselves.
What I am asking is as follows:
1) Is there a way to count only one space after each word and ignore multiple spaces?
2) Can I prevent multiple spaces in the textarea?
Since I am suspecting that the solution dwells within the realm of javascript, I kindly ask for your help as I am still a noob. I will be grateful for any suggestions, be it 1) or 2).
HTML:
<div class="options">
Task:
<textarea type="text" rows="10" cols="97" name="task" id="task" onkeypress="onTestChange01();"
autocorrect="off" spellcheck="false"></textarea>
<p>Word count: <textarea cols="10" name="count" id="count" readonly>0</textarea></p>
</div>
JAVASCRIPT:
// WORD COUNTER FUNCTION
var count = document.getElementById('count');
var input = document.getElementById('task');
input.addEventListener('keyup', function(e){
wordCounter(e.target.value);
});
function wordCounter(text) {
var text = input.value;
var wordCount = 0;
for (var i = 0; i <= text.length; i++) {
if (text.charAt(i) == ' ') {
wordCount++;
}
}
count.innerText = wordCount;
}
I tried fiddling with the JS function and its values.
Also, I found a function to change multiple spaces to one space, which did not work as expected and it disrupted the original function and the counting.
Finally, I tried preventing 'space' altogether in the textarea properties but all in vain.
Looking forward to your ideas. Thanks.
tk
I have an TYPO3 extension which shows a list of records. As it are more than 40 pages I would like to provide an additional alphabetic index which enables visitors to jump directly to the beginning of a character.
In general all is working - except the link to the n-th page.
I have the fluid variables cur containing current character (e.g. M) and the necessary page number in pageNumber (e.g. 23).
How can I get the correct url which should look like:
https://mydomain.tld/path/to/list?tx_myextension_myextension[#widget_0][currentPage]=23&cHash=a6193a7eab129df4789343911221584b#jumplabel_M
either
<a class="page-link" href="{f:uri.page(additionalParams:{tx_myextension_myextension{#widget_0:{currentPage:pageNumber}}})}#jmplabel_{cur}">{cur}</a>
nor
<a class="page-link" href="{f:uri.page(additionalParams:{tx_myextension_myextension[#widget_0][currentPage]:pageNumber})}#jmplabel_{cur}">{cur}</a>
call the f:uri.page VH. The result is an unreplaced string in the href-parameter.
<a class="page-link" href="{f:uri.page()}?tx_phonebook_phonebook[#widget_0][currentPage]={pageNumber}#jmplabel_{cur}">{cur}</a>
looks ok, but misses the cHash and therefore results in 404 page not found.
Check how Georg Ringer does it in his News extension. Actually that's a solution for your pagination.
PaginateAdditionalParamsViewHelper.php:
https://github.com/georgringer/news/blob/master/Classes/ViewHelpers/Widget/Ajax/PaginateAdditionalParamsViewHelper.php#L30
public function render()
{
$page = (int)$this->arguments['page'];
if ($page === 0) {
return [];
}
$params = [
'tx_news_pi1' => [
'#widget_0' => [
'currentPage' => $page
]
]
];
return $params;
}
And in some template:
https://github.com/georgringer/news/blob/master/Resources/Private/Templates/Styles/Twb/Templates/ViewHelpers/Widget/Paginate/IndexAjax.html#L56, especially additionalParams key.
<f:widget.link data="{container:recordId,link:'{t:uri.ajaxAction(contextRecord:\'tt_content:{recordId}\', pluginName: \'pi1\',additionalParams:\'{n:widget.ajax.paginateAdditionalParams(page:0)}\')}'}">
<f:translate key="paginate_previous" />
</f:widget.link>
Dears,
I have arabic sentence like this stentence
أكل الولد التفاحة
how can i split the sentence based on UNCONNECTED characters to be like this :
أ-
كل
ا-
لو-
لد
ا-
لتفا-
حة
I put - to explain what i mean.
I just need to split the text into array based on that
How can i do that using swift code for ios ?
Update:
I dont care for the spaces.
"أكل" for example is one word and doesn't contain spaces.I want to split based on UNCONNECTED characters.
So "أكل" consist from two objects : "أ" and "كل"
الولد : three objects "ا" and "لو" and "لد"
Use the below code:
let a = "أكل الولد التفاحة".split(separator: " ")
You can replace spaces with "-" using replacing occurences function.
let text = "أكل الولد التفاحة".replacingOccurrences(of: " ", with: "-", options: NSString.CompareOptions.literal, range: nil) ?? ""
I don't know how accepted answer helps to fix the issue.
Apple already provided Natural Language Framework to handle such a things which more trustworthy
When you work with natural language text, it’s often useful to tokenize the text into individual words. Using NLTokenizer to enumerate words, rather than simply splitting components by whitespace, ensures correct behavior in multiple scripts and languages. For example, neither Chinese nor Japanese uses spaces to delimit words.
Here is example
let text = """
All human beings are born free and equal in dignity and rights.
They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood.
"""
let tokenizer = NLTokenizer(unit: .word)
tokenizer.string = text
tokenizer.enumerateTokens(in: text.startIndex..<text.endIndex) { tokenRange, _ in
print(text[tokenRange])
return true
}
Here is link of Apple docs
Hope it is helpful
There is two box you can just click in first. Content automatically paste click convert. Output data automatically copied with spaces I used for this quran
<h1>Allah</h1>
<center>
<textarea id="field" onclick="paste(this)" style="font-size: xxx-large;min-width: 90%; min-height: 200px;"> </textarea>
<center>
</center>
</br>
<textarea id="field2" style="font-size: xxx-large;min-width: 95%; min-height: 200px;"> </textarea>
</center>
<center>
<br>
<button onclick="myFunction()" style="font-size: xx-large;min-width: 20%;">Convert</button>
</center>
<script >
function myFunction(){
var string = document.getElementById("field").value;
// Option 1
string.split('');
// Option 2
console.log(string);
// Option 3
Array.from(string);
// Option 4
var bb = Object.assign([], string);
console.log(bb);
cleanArray = bb.filter(function () { return true });
var filtered = bb.filter(function (el) {
return el != null; });
console.log(filtered);
var bb = bb.toString();
console.log(bb);
bb = bb.replace(",","");
var stringWithoutCommas = bb.replace(/,/g, ' ');
console.log(stringWithoutCommas);
document.execCommand(stringWithoutCommas)
document.getElementById("field2").value = stringWithoutCommas;
var copyTextarea = document.querySelector('#field2');
copyTextarea.focus();
copyTextarea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
};
/*
var copyTextareaBtn = document.querySelector('#newr');
copyTextareaBtn.addEventListener('click', function(event) {
var copyTextarea = document.querySelector('#field2');
copyTextarea.focus();
copyTextarea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
});
*/
async function paste(input) {
document.getElementById("field2").value = "";
const text = await navigator.clipboard.readText();
input.value = text;
}
</script>
Try this:
"أكل الولد التفاحة".map {String($0)}
Im doing MVC4 application and Im creating Selenium tests for it. My problem is that I want to find element <ul class="connectors ui-sortable"></ul> but only contained in <li class="empty zoneLi ui-droppable" data-order="X">
My solution was one added below, but it's not working:
private static IWebElement FindZoneByDataOrder(IWebDriver webDriver, int dataOrderId)
{
var parentForDropElement = webDriver.FindElement(By.XPath("//li[#data-order='" + dataOrderId + "']"));
var dropElement = parentForDropElement.FindElement(By.XPath("//ul[#class='connectors ui-sortable']"));
return dropElement;
}
part of my HTML page:
....
<div class="zones-system-creator" style="min-height: 430px;">
<ul id="zonesCreateSystem" class="">
<li data-zoneid="24829" class="empty zoneLi ui-droppable" data-order="1">
<div id="warningInfoBoxContainer"></div>
<ul class="products ui-sortable"></ul>
<ul class="connectors ui-sortable"></ul>
</li>
</ul>
</div>
....
UPDATE1: I changed zoneID to dataOrderId, because we care only about dataOrderId.
I see few issues in your code. You talked about data-order, but passed zoneId in the method. So I have added another parameter called dataOrder and searching for the LI element which has both zone and data order attributes:
"//li[#data-zoneid='" + zoneId + "'][#data-order='"+dataOrder+"'"]
Then searching for ul element of having specified class. Also combined finding the element into a single line:
Code:
private static IWebElement FindZoneByDataOrder(IWebDriver webDriver, int zoneId, int dataOrder)
{
return driver.findElement(By.xpath("//li[#data-zoneid='" + zoneId + "'][#data-order='"+dataOrder+"']//ul[#class='connectors ui-sortable']"))");
}
Edited Answer following question edit:
return driver.findElement(By.xpath("//li[#data-order='"+dataOrderId+"']//ul[starts-with(#class, 'connectors')]"));
I found 2 working solutions if you want to find one element inside the other with Selenium:
result = webDriver.FindElement(By.XPath("//li[#data-order='" + dataOrderId+ "']"));
var result2 = result.FindElement(By.XPath(".//ul[#class='connectors']"));
result = webDriver.FindElement(By.CssSelector("li[data-order='" + dataOrderId+ "']"));
result = result.FindElement(By.CssSelector("ul[class='connectors']"));
Is there anything I can use instead of 'a' selector. Maybe something like <url href=""> or something similar. I'm trying to avoid 'a'. The reason for that is that I'm working with jQuery and its code modyfying every 'a' in the section. I want to keep some 'a's untouched. This is what i have:
HTML:
<div> <!-- █ POST █ -->
<h3>14 June 2012 - Noisettes for Spotify</h3>
<p>
We have supplied a sound equipment for the Noisettes concert on Spotify company event. Please enjoy <a class="inlink" target="_blank" href="http://www.youtube.com/watch?v=KRFHiBW9RE8">Noisettes on YouTube</a>.
</p>
</div>
JQUERY:
$(document).ready(function(){
var $posts = $('#items > div');
var maxHeight = 32;
$('a', $posts).live('click', function(){
var $par = $(this).prev('p');
var oH = parseInt($par.attr('class'));
if($par.height() == oH){
$par.animate({
'height': maxHeight
}, 'medium');
$(this).text('read more...');
}else{
$par.animate({
'height': oH
}, 'medium');
$(this).text('read less...');
}
});
$posts.each(function(){
if($('p', this).height() > maxHeight){
$('p', this)
.attr('class', $('p', this).height())
.css('height', maxHeight+'px');
$(this).append($('<a class="link">').text('read more...'));
}
});
});
It replaces my 'Noisettes on YouTube' (from html code) with 'read less...' (still working but wording changes. I was trying to use CSS but it still replaces it.
I hope I made myself clear on this :) Thanks for help in advance.
You should use a more specific selector:
$posts.find('a.SomeClass')...
Then change the links that you want this to apply to to <a class="SomeClass">.
Give all the "a" that you want to change a particular class, say "changeable", and then change your selector from $('a', $posts) to $('a.changeable', $posts)