News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

SMF 2.1 - Change calendar 'Location' field to input box

Started by GL700Wing, February 09, 2024, 12:55:36 AM

Previous topic - Next topic

GL700Wing

By default the 'Location' field for Calendar events, which allows up to 255 characters, is displayed as an input line in which entered text does not wrap during input/editing.

This tip/trick displays the 'Location' field as an input box in which entered text wraps during input/editing.

In ./Themes/default/Calendar.template.php
Find:
<input type="text" name="event_location" id="event_location" maxlength="255" value="', !empty($context['event']['location']) ? $context['event']['location'] : '', '" tabindex="', $context['tabindex']++, '">
Replace with:
<textarea name="event_location" id="event_location" maxlength="255" style="height: 100px;" maxlength="255" tabindex="', $context['tabindex']++, '">', !empty($context['event']['location']) ? $context['event']['location'] : '', '</textarea>
You cannot view this attachment.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

ColinJM

Exactly what I was after GL - great minds think alike  ;D - how do you get the text to wrap please?
Kind Regards

Colin

GL700Wing

Quote from: ColinJM on February 09, 2024, 02:36:59 AMExactly what I was after GL - great minds think alike  ;D - how do you get the text to wrap please?
It's the normal behaviour of a 'textarea' field ...
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

ColinJM

Kind Regards

Colin

GL700Wing

Quote from: ColinJM on February 09, 2024, 02:54:06 AMOK, but mine is not wrapping?
Strange - that's the only change I made and as per the second screen capture the text wraps in the field.

That said, it's still a single line of text and will display that way in the calendar even if you put line breaks in the 'Location' text ...
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

GL700Wing

Make the code change below if you want line breaks in the 'Location' field to also display as line breaks when the event is shown in the calendar as per the following image:
You cannot view this attachment.

In ./Themes/default/Calendar.template.php
Find:
if (!empty($event['location']))
echo '<br>', $event['location'];

Replace with:
if (!empty($event['location']))
echo '<br>', nl2br($event['location']);
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

ColinJM

OK - will give that a go and report back GL - thankyou!
Kind Regards

Colin

ColinJM

Kind Regards

Colin

GL700Wing

Quote from: ColinJM on February 09, 2024, 07:47:00 PMHmmm - my code is slightly different?
Think you're in the wrong location ...

In an original SMF 2.1.4 template file the first edit is done on line 888 and the second edit is done on line 151 (lines 150 and 151 are shown).
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

ColinJM

Kind Regards

Colin

ColinJM

Kind Regards

Colin

Advertisement: