Formatting the Calender Events on the First Page

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

Previous topic - Next topic

lemur21

My site is super-locked down ...

The screenshot above is what the section looks like (based on the template file I posted earlier -- that you looked at).

Does that make sense?

I need the date to stay with the info (which is probably where the   $member['date']   comes in (but, if you have a better way to retain the date *and* put the line breaks in, I'm all for it) :)

lemur21

I can send you a PM to get you onto my site, if you need that ... I have to open registration, accept you, etc. and I'd need your email address (which I'm sure you don't want to post here, publicly) ...

But, the attached screenshot above is what the site looks like, currently (I changed the color on the css, as you provided) .....

Pipke

think this is what you need


// 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 '
', $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 /> ';
}
// add line
if (!empty($context['calendar_events']) && (!empty($context['calendar_birthdays'])))
echo'<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 />';
}
"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

Bam! You are correct. Attached the screen shot below, to show you the finished product!

Now, I'll eventually save all these threads and read over them to figure out what you did, so I can -- hopefully -- learn from it.

Thank You. Thank You. Thank You. I truly appreciate it!


Pipke

ok nice you got it working now, also you can change the date output format, the date is now with the year 2016, wich i think isn't relevant, try this code.


// 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 date('jS F', strtotime($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 /> ';
}
// add line
if (!empty($context['calendar_events']) && (!empty($context['calendar_birthdays'])))
echo'<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>'.date('jS F', strtotime($event['start_date'])).' - ' . $event['title'] . '</strong>' : date('jS F', strtotime($event['start_date'])).' - '.$event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br />' : '<br />';
}


"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

Interesting -- I was doing some looking at strotime php (on google). I like that you can adjust it, but I don't like this output, necessarily.

Previously, it looked like this:   2016-3-25

Now, it looks like this: 25th March

I'd prefer it to look like this: 3-25

I see where the change occurs (you added in: date('jS F', strtotime  --- I just need to see if I can figure out how to change it :)

lemur21

Yay! I did it (changed it to

date("m-d",strtotime

I can play with that and see if I like changing it to "March 25" instead of 03-25, but I can live with either one, I suspect

lemur21

Silly, dumb, final question (only b/c I don't know where to find it, Pipke).

I was able to change the output (as discussed above) to the "m-d" format. But, it looks as though - if an event is TODAY, the font size (and, maybe the font, itself) changes.

See screenshot.

Where is this command located? Doesn't seem to be in BoardIndex.Template. php; nor does it seem to be in my theme/index.css file (where I thought it would be).

Or, are my eyes just playing tricks on me, now?

Advertisement: