Title on two lines


Matrix Version:
Is there any way to split a title on to two separate lines? I.e. insert something into the text box that acts like a break tag.

(Peter McLeod) #2

If you are doing it manually in a textarea element you would use ā€˜\nā€™.
To do it dynamically on a matrix keyword, you could use server side js.
For example if you are trying to split a string at its mid point you could do something like:

<script runat="server">
    var breakType = "\n"; //define the type of line break, \n or <br>
    var title = "%asset_name%"; //set the title from a keyword
    var words = title.split(" "); //create an array of words
    if (words.length == 1){ //if only 1 word then print it
    } else { 
        var middleIndex = Math.round(words.length / 2); //find the middle word
        var middleWord = breakType + words[middleIndex]; //prepend the line break to it
        words[middleIndex] = middleWord; //reset the value of the middle word with the new one
        print(words.join(" ")); //join the words and print


(Bart Banda) #3

You could just use a textarea and hit enter and then use the ^nl2br keyword modifier when printing the value on the frontend?