Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-08-30 20:44:33

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,284

[request] wrapping and formatting titles

Though I’m very content with most of the possibilities txp is offering, I had the need from the very beginning to have more control over the way txp wraps titles. So I reanimated alexandra’s thread and asked for something that would break a title at a given point.
Skubidu seemed to understand me well and posted this snippet:

<code><txp:php>global $thisarticle; echo str_replace(“///”, “<br />”, $thisarticle[‘title’]);</txp:php></code>

With some earlier objections of wet and zem in mind and at least being able to understand what skubidu’s code does (but not capable of writing just one line by myself), I figured out, that it could be possible to write a snippet or plugin, that does even more than just replacing a sequence of nonsese letters. My idea looks like this:

If an article’s author wants to break a line after a certain word, he enters just that word in a custom field, and the php-function, fed with the content of the field’s value, breaks the line after the desired word. If no value is entered, everything works just as always.
This way authors keep their fingers off of the code, and titles can be re-used at any other location of the site without visible traces in them. And, almost best of all, titles can be formatted in at least two different styles (depending on the number of custom fields used for this), as adding XHTML tags to the beginning, the middle, and the end of the title can be done in one.

But you may have even more and better ideas.

I guess there seems to be a certain need at least for controlling where a title gets wrapped, as the thread that came up with this idea is the most read one on the first page of the “how do i …?”-forum, being opened 305 times at this moment. (minus 22 poster’s clicks, … , calculated generously, … , let’s say … 150. Is this enough?)

Last edited by uli (2006-08-30 20:50:29)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#2 2006-08-30 21:16:56

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

Re: [request] wrapping and formatting titles

Hi Uli!

If you don’t need your plugin now and can wait about one or two month (I have to finish my thesis at university first), you could wait for a new release of nhn_typotuner (info in German) which will be able to handle these cases.

Nils

Last edited by Skubidu (2006-08-30 21:18:13)

Offline

#3 2006-08-31 12:03:21

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,284

Re: [request] wrapping and formatting titles

Hi Nils,

one or two months would be sufficient, though I personally can’t wait to use it ;) And “these cases”, as you say, sounds promising. Do you still plan to let Textile do the job of formatting the titles, the same way that typotuner does? In this case I can only hope I’ll get Textile to work with styles, I’ve had no success yet, even when I copied the characters of the help. But I’d prefer to keep text completely apart from any coding, chosing styles by selecting several significantly named txp forms might be sufficient.

The way typotuner works now is (txp-)form based and thus predetermined. Do you plan to handle things more flexible, perhaps the way like I outlined in my first post?

Last night I came up with another benefit of using a blank field. One can even use it for dividing a word: applying your snippet, no hyphen would be set if you fill in the first part of a word as an indicator where to break the line. But you could tell the function to leave a hyphen as the last character on the first line if one is supplied as the last element of the custom field.

Btw, good luck and success with your thesis!


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2006-08-31 13:41:25

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

Re: [request] wrapping and formatting titles

The way typotuner works now is (txp-)form based and thus predetermined. Do you plan to handle things more flexible, perhaps the way like I outlined in my first post?

I’m open for ideas :)

Offline

#5 2006-09-08 10:21:16

juanjonavarro
Plugin Author
From: Valencia, Spain
Registered: 2005-05-16
Posts: 485
Website

Re: [request] wrapping and formatting titles

I did it for you.

Offline

#6 2006-09-08 15:54:28

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,284

Re: [request] wrapping and formatting titles

Thank you, Juanjo! Good job! I’m glad, that I can use this one right now. I’ve put an “advertising” ;) text in the according thread.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#7 2006-09-08 22:52:03

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [request] wrapping and formatting titles

FYI, the Textpattern 4.0.4 pre-release already has built-in support for the widont idea, via the <txp:title no_widow=1 /> attribute.


Alex

Offline

#8 2006-09-09 13:29:37

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,284

Re: [request] wrapping and formatting titles

this is great news, zem! any automatism is better than spending time and thoughts for considerations about where a line is broken best. by this feature 4.0.4 will probably cover the needs of more than 90% of all designers and authors, who have been missing it, i think.

but there are even deeper needs, as the german language for instance tends to concatenating nouns into word monstrosities like this one:
&laquo;herausforderungen durch unvereinbarkeiten in der sozialpädiatrischen kinderfrühförderungsberatung: entscheidungshilfen für elternberatungsgesellschaften in der kinder- und jugendpsychotherapie.&raquo; :))
which cries for syllabification! the english speaking community can be lucky to use words with an estimated average of 6 – 8 letters.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#9 2006-09-10 23:18:47

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [request] wrapping and formatting titles

Uli: is there a reasonable compromise for this, like hyphenation or similar?

I’ve been experimenting with the zero-width space character () for “soft” word wrapping. This gives the browser a place to wrap words when required, but stays invisible when wrapping is unnecessary. We could try something like, inserting a zero-width space in words that have more than n characters.

Last edited by zem (2006-09-10 23:25:18)


Alex

Offline

#10 2006-09-11 12:09:20

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,284

Re: [request] wrapping and formatting titles

zem, i’m really glad that you understand this need and that you’ve been thinking about solutions for it. i’m sorry that i have to say that i(!) can’t imagine a compromise, as there is the need of correct spelling and thus correct separation. this doesn’t mean, that i’m not open for compromises, rather i don’t know which software techniques could contribute to a compromise.

the last german spelling reforms open the possibillity of writing apart a multitude of formerly concatenated verbs and adjectives, but not nouns. for the example sentence above there is no single instance where these new rules apply. certain concatenations can now be written with a hyphen, AFAIK this applies to two words in the example. provided even that browsers support hard hyphenation, the improvement is not too big.

the output of simply adding zero-width spaces to every point of separation possible, without further treatment by txp, would give no correct solution, at least in the three languages i know. but if you’re planning a txp-internal recognition of line wrapped words that were separated at such a predetermined breaking point, inserting a hyphen as the last character on the line, this might be the perfect workaround for the lack of <code>&shy;</code> support. edit: browser windows can be resized. :/

Last edited by uli (2006-09-11 12:15:09)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#11 2006-09-11 23:26:25

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [request] wrapping and formatting titles

edit: browser windows can be resized. :/

That, and the fact that designs change independent of content, is why I’m not so keen on fixed line breaks in titles.

What about this: a soft hyphen or zero-width space optionally inserted in words that are longer than n characters. Perhaps <txp:title maxword=32 /> or similar. Maybe it needs to count line length instead, or both. That sounds more like plugin territory though.

Last edited by zem (2006-09-11 23:26:51)


Alex

Offline

#12 2006-09-12 01:11:30

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,284

Re: [request] wrapping and formatting titles

That, and the fact that designs change independent of content, is why I’m not so keen on fixed line breaks in titles.

i have fixed width containers in both of my two txp projects so far. you often have it in side bars, forms, catalogue layouts, … so far for resizing windows.
but i agree: designs can change, at least there is a chance. we’ve had that, elsewhere ;)

What about this: a soft hyphen or zero-width space optionally inserted in words that are longer than n characters.

who inserts them, writers or a function? or what is this n characters thing for? n is used more precisely for the min length of syllables. but there are 1-letter syllables in english, right? we don’t have them here.
how do you see would an optional breakpoint be inserted manually? by typing & shy or & #8203? just letting my thoughts run: by a button to push at the current position of the insertion mark? offer several marks: to be chosen from a menu. add goodies to that menu. leading/trailing thumbnails, symbols, styles, tags, spans, (i think about formatting things like special/price, date/location, or artist/album/title in headlines)

Perhaps < txp:title maxword=32 /> or similar. Maybe it needs to count line length instead, or both.

any kind of counting would be nice. like mentioned above: could this work in flexible width layouts even after a window resize? hm, a javascript injection?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB