Formatting the Calender Events on the First Page

Started by lemur21, March 13, 2016, 04:22:04 PM

Previous topic - Next topic

lemur21

Years ago, I asked about formatting calendar events on the home page.

Specifically, I had to adjust the calendar.template.php file to allow me to have titles for calendar events exceeding 30 characters (I've set mine to 60).

But, also, I wanted to be able to set up the 'upcoming events' on the index page to list each event with its respective date; and be placed on it's own line.

So, for example, if I list all events for the next 60 days, I get: Upcoming events: GameDay*, GameDay*, GameNite*, GameDay*. I'd rather it look like this:

9/30 - GameDay*
10/21 - GameDay*
10/27 - GameNite*

(where the date could be that format or any other real format).

I was able to get that working in my 1.1 install (10 years ago) - you can read all about it here:   http://www.simplemachines.org/community/index.php?topic=116873.0

But, I'm unable to get it done in my 2.0 install (which -- obviously -- wiped out my customizations).

One thing I also noticed -- in 2.0, birthdays and events are automatically separated already; which is probably why the syntax doesn't match, as well.

I've asked a few questions here -- most have (thankfully) been solved ... this is the last one outstanding (and, since it DID work in the past, I know it's possible ... I just need someone to tell me the code to add, and where, since the syntax in the files has changed ........)

Thanks so much!

lemur21

Bumping ....

Is Codenaught (akabugeyes) no longer around? He was the one who figured this out the first time ...........

Illori


Steve

DO NOT pm me for support!

lemur21

Damn ...

Is he the only one that knew how to do stuff like this?  LOL .....

lemur21

Ok .. a MAJOR update on this ......

I was able to use some of the code submitted 10 years ago (into BoardIndex.Template to set the events to their own line WITH the date (see the screenshot). I was also able to get the birthdays onto their own lines, as well.

What I don't have yet - is the way to carry the date *from* the calendar to the board index for birthdays (it's happening for events already).

It looks like (from way back when) that this was done through BoardIndex.php -- in "Sources" -- and here's what was recommended to me way back then:




Open Sources/BoardIndex.php

Find:

Code: [Select]

         foreach ($bday[strftime('%Y-%m-%d', $i)] as $index => $dummy)
            $bday[strftime('%Y-%m-%d', $i)][$index]['is_today'] = strftime('%Y-%m-%d', $i) == strftime('%Y-%m-%d', forum_time());


Change to:

Code: [Select]

         foreach ($bday[strftime('%Y-%m-%d', $i)] as $index => $dummy)
         {
            $bday[strftime('%Y-%m-%d', $i)][$index]['is_today'] = strftime('%Y-%m-%d', $i) == strftime('%Y-%m-%d', forum_time());
            $bday[strftime('%Y-%m-%d', $i)][$index]['date'] = strftime('%Y-%m-%d', $i);
         }



However, there is NOTHING like that in the BoardIndex file ... this is the last thing I need ... any insights? :)

Thanks, as always!

lemur21

#6
In the event this is actually taken care of in BoardIndex.Template now -- here's the relevant code from there:

Remember -- the "events" do appear on an individual line *with* the date; while birthdays appear on individual lines, but without the date.

Should this change (having birthdays include the date) be taken care of in the BoardIndex.Template file (below) or in BoardIndex (listed above, as it was 10 years ago)?



// People's birthdays. Like mine. And yours, I guess. Kidding.
if (!empty($context['calendar_birthdays']))
{
echo '
<span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span> ';
/* Each member in calendar_birthdays has:
id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) */
foreach ($context['calendar_birthdays'] as $member)
echo '
', $member['date'], ' -
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<b>' : '', $member['name'], $member['is_today'] ? '</b>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a> <br /> ';
}
// Events like community get-togethers.
// Events like community get-togethers.
if (!empty($context['calendar_events']))
{
echo '
<span style="color: #', $modSettings['cal_eventcolor'], ';">', $context['calendar_only_today'] ? $txt['calendar4'] : $txt['calendar4b'], '</span> ';
/* Each event in calendar_events should have:
title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. */
foreach ($context['calendar_events'] as $event)
echo '
', $event['date'], ' - ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<b>' . $event['title'] . '</b>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br />' : ', <br /> ';
}
echo '
</p>';

Illori

would you mind stop cross posting? please pick one topic and stick to that one for updates. if you wish you can drop a reply with the link to the other topic and be done with it.

lemur21

:(

Imagine my disappointment, to see a reply, and for it to be this (and, with a "like" already, before I even got here ...). I don't even know HOW to like things on this board.

I don't anticipate posting anymore updates except -- hopefully -- a "Solved" - but, as it's been, almost a month, that seems to be folly.

I'll still hold out hope -- I've come a long way for someone with NO programming experience. I'd just prefer to not break something permanently (especially when, I *think* it's a fairly easy fix for someone who knows the SMF architecture) ....

If there's a better place for me to ask this question, I'm all for it ... I'd just like to fix this and have my forum back to where it was before everything had to change :(

I can't delete the other thread -- tried :(

lemur21

Quote from: lemur21 on March 19, 2016, 04:52:31 PM
(and, with a "like" already, before I even got here ...). I don't even know HOW to like things on this board.


Never mind.

lemur21

Live627 seems to have solved the issue with the dates and birthdays. I do now have dates with the birthdays ... thank you so much, Live627!

But, in my tinkering, I may have broken one other thing (almost certainly not from Live627's fix) .... I *thought* when I first moved up to 2.0, I had a separation between birthdays and "events' -- where it would list "Upcoming birthdays" and "Upcoming events" --  now, it's all under "upcoming events"  (see screenshot)

This is almost certainly something easy to fix (for some reason, i think the default in SMF 2.0 is to have them separated?)

Anyway, I've also been asked to direct everything to ONE thread, so this is the thread I'll keep updating:

Thank you so much, once again! I see a light at the end of the tunnel!

Pipke

go in ../Themes/{your_theme}/BoardIndex.template.php

Code (find) Select

// Events like community get-togethers.
if (!empty($context['calendar_events']))
{
echo '
<span class="event">', $context['calendar_only_today'] ? $txt['events'] : $txt['events_upcoming'], '</span> ';
/* Each event in calendar_events should have:
title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. */
foreach ($context['calendar_events'] as $event)
echo '
', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><img src="' . $settings['images_url'] . '/icons/modify_small.gif" alt="*" /></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br />' : ', ';
}


Code (replace by) Select

// Events like community get-togethers.
if (!empty($context['calendar_events']))
{
echo '
<span class="event">', $context['calendar_only_today'] ? $txt['events'] : $txt['events_upcoming'], '</span><br /> ';
/* Each event in calendar_events should have:
title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. */
foreach ($context['calendar_events'] as $event)
echo '
', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><img src="' . $settings['images_url'] . '/icons/modify_small.gif" alt="*" /></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>'.$event['start_date'].' - ' . $event['title'] . '</strong>' : $event['start_date'].' - '.$event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br />' : '<br />';
}


result see Attachment
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

lemur21

Pipke - yes ... this worked almost perfectly! I have one quick question (but I'm going to PM you, since I don't believe any "code" needs to be written, I just need to know where to find the piece of code that differs ... you'll see)!

Thank you so so so so much!

Pipke

Quote from: lemur21 on March 21, 2016, 09:36:31 AM
And, in an effort to make both look the same -- here's the difference:

1. The text color for "Upcoming birthdays" and "Upcoming events" is actually different - but I don't see anything in the code here that would define the color. Is that just default? (and, if it is, that's okay)

2. The Upcoming Events looks *exactly* the way I want it to -- it has the title "Upcoming Events" on one line, with each subsequent event on a separate line below that. The Upcoming Birthdays, though, has the first birthday on the SAME line as the title, with each subsequent birthday on a separate line below that.

How can I get the Birthdays to follow the same format as Events (which you've set up) --  and, secondly, is there any way to have a blank line between the last birthday and the Upcoming Events title (I'm assuming an additional <br/> is needed; does it just insert into the code between the two modules above?

Thanks so much! I truly appreciate it!


Code (result attachment 1) Select

// People's birthdays. Like mine. And yours, I guess. Kidding.
if (!empty($context['calendar_birthdays']))
{
echo '
<span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span><br /> ';
/* Each member in calendar_birthdays has:
id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) */
foreach ($context['calendar_birthdays'] as $member)
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong>' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '<br />' : ', ';
}
// Events like community get-togethers.
if (!empty($context['calendar_events']))
{
echo '
<br /><span class="event">', $context['calendar_only_today'] ? $txt['events'] : $txt['events_upcoming'], '</span><br /> ';
/* Each event in calendar_events should have:
title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. */
foreach ($context['calendar_events'] as $event)
echo '
', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><img src="' . $settings['images_url'] . '/icons/modify_small.gif" alt="*" /></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>'.$event['start_date'].' - ' . $event['title'] . '</strong>' : $event['start_date'].' - '.$event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br />' : '<br />';
}


to change the titles of 'events' and/or 'birthday' colors you must go in ../Themes/{your_theme}/css/index.css
around line 568 you will find and edit the hex color

Code (result attachment 2) Select

.birthday
{
color: #920ac4;
}

.event
{
color: #078907;
}


like if you would like both green do this:
Code () Select

.birthday
{
color: #078907;
}

.event
{
color: #078907;
}




"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

lemur21

#14
Hmmm ... this didn't work (the first part) -- I suspect, because I already have other modifications to the BoardIndex.Template file (?) When I put your code in, it DID set up the line breaks, but got rid of the dates in front of each birthday.

So, then I started playing around (thankfully, I backed up the original file) - and I *still* can't get it right. Either I lose the date or I lose the line break.

The color change DID work. We're nearly there (and, seriously, thank you so much for your help!)

Let me post the code here. This is different from the default code, I suspect:



// People's birthdays. Like mine. And yours, I guess. Kidding.
if (!empty($context['calendar_birthdays']))
{
echo '
<span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span> ';
/* Each member in calendar_birthdays has:
id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) */
foreach ($context['calendar_birthdays'] as $member)
echo '
', $member['date'], ' -
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<b>' : '', $member['name'], $member['is_today'] ? '</b>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a> <br /> ';
}
// Events like community get-togethers.
if (!empty($context['calendar_events']))
{
echo '
<span class="event">', $context['calendar_only_today'] ? $txt['events'] : $txt['events_upcoming'], '</span><br /> ';
/* Each event in calendar_events should have:
title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. */
foreach ($context['calendar_events'] as $event)
echo '
', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><img src="' . $settings['images_url'] . '/icons/modify_small.gif" alt="*" /></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>'.$event['start_date'].' - ' . $event['title'] . '</strong>' : $event['start_date'].' - '.$event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br />' : '<br />';
}

echo '
</p>';
}


--edit by kindred - please use code BBC when posting code

Pipke

look at my code and yours on the template file from the line-->  // People's birthdays. Like mine. And yours, I guess. Kidding.
under that it must look like i posted and it should work, if you cannot get it working pls post your template file and i will edit it for ya.
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

lemur21

I did initially copy & paste; but when I did that, it eliminated the date and dash before each birthday (which was in there from a previous edit change).

Here's the file

Pipke

$member['date'] is not defined, where you got that from?
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

lemur21

That was the change to add the date before the birthday event ....

That's something I added when I was trying to replicate it (from this thread: http://www.simplemachines.org/community/index.php?topic=116873.msg751460#msg751460) 10 years ago.

If you can eliminate that *and* keep the date, dash, birthday -- on separate lines, with a line between the last birthday and the first event, that's fine -- I was trying my hand at trouble-shooting, and was ecstatic that I figured that much out.

FWIW - here's what it looks like right now (screenshot)

Pipke

does the birthday date show up now at your site?, i'm getting confused what you want, can you post your website url.
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Advertisement: