Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Mod Requests => Topic started by: lemur21 on March 01, 2016, 05:13:24 PM

Title: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 01, 2016, 05:13:24 PM
Hello all,

So - a while back (about 10 years, in fact!) I set up my SMF board ... and didn't touch it again. Recently, due to a variety of factors (outdated PHP, incompatibility, etc.) I had to upgrade to 2.0.11, which meant -- functionally -- setting everything up all over again.

There were two things I did for my forum, way back when, that I want to replicate (and, unfortunately, I was never a techie; and I've forgotten the little I *did* know). At the time, I was able to be given a little code, and I altered the documents myself -- but, it's starting to occur to me (based on the lack of feedback), that perhaps these are better serves as actual mods?

The first thing I changed was labeling Polls and Sticky Topics and Locked Topics (here's the link to the original discussion -- nearly 10 years ago!):

http://www.simplemachines.org/community/index.php?topic=34629.0

The second changed the way Calendar Events were displayed on the front page (and, again, the link):

http://www.simplemachines.org/community/index.php?topic=116873.0

Certainly, the syntax in the files that I updated has changed from 1.1 to 2.0. I also think these are non-theme dependent (but, in case it matters, I am using a custom theme (Blue Star)).

Thanks so much in advance!
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: margarett on March 01, 2016, 05:24:38 PM
The first one should actually be really similar, the code is pretty much the same:
', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], (!$context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', $topic['is_sticky'] ? '</strong>' : '';

And I'm betting that the second should also be similar, Calendar is also very similar.
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 01, 2016, 05:30:48 PM
Margarett -- I was hoping / thinking the same ....

But, when I did an initial search for what I was told to look for originally, I couldn't find the code (I'm NOT a techie, at all). So, for me, it's literally a case of search/replace/paste ... and I can do that.

I *did* think this was a fairly simple fix (because it was fixed so quickly when I first did it all those years ago) -- but, I really need "Hey - paste <this code> here <location of old code>"

:)

Thanks so much!
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: margarett on March 01, 2016, 06:21:36 PM
OK I'll have a peek at that tomorrow ;)
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 01, 2016, 06:24:32 PM
Margarett ...

That would be AWESOME (with not just a capital A, but ALL capital letters) ....

Thanks so much!
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 06, 2016, 10:27:12 AM
Bumping ...

Would love to be able to make these changes on Tuesday -- assuming I can get the info  O:)  It's a good time to take the forum down, just in case things don't go correctly ...............

TIA
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: margarett on March 10, 2016, 07:51:56 PM
OK, let's do this properly. No theme edits, all languages properly defined

The Poll, locked, sticky thing.
Sources/MessageIndex.php, find:
// 'Print' the topic info.
Add before: (you can change the priority at will)
if (!empty($row['locked']))
$pre_subject = $txt['lemur21_locked'];
else if (!empty($modSettings['enableStickyTopics']) && !empty($row['is_sticky']))
$pre_subject = $txt['lemur21_sticky'];
else if ($modSettings['pollMode'] == '1' && $row['id_poll'] > 0)
$pre_subject = $txt['lemur21_poll'];
else
$pre_subject = '';

Find:
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['first_subject'] . '</a>'
Replace with:
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $pre_subject . $row['first_subject'] . '</a>'

Themes/default/languages/Modifications.english.php, add before the end (a line before ?>)
$txt['lemur21_sticky'] = 'Sticky: ';
$txt['lemur21_locked'] = 'Locked: ';
$txt['lemur21_poll'] = 'Poll: ';


The calendar... Didn't get there yet, I need days with more hours...
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 12, 2016, 03:49:39 PM
YES! Thank you so much, Margarett! This worked!

I was suspicious, because I didn't know why the code included my user name here on the forum (lemur21) -- out of curiosity, why is that?

Also - second question (and this may be the behavior of SMF by itself) -- the 'Sticky" topics now have "Sticky" preceding the topic name, and the entire "headline" is bold. The Poll has "Poll" before the name, but it's not bold. Was that something that changed through this update, or, are Sticky topics always bold by default (and, if so, is there an easy way to make Polls bolded as well?)


All I'm waiting on - now - is the Calendar stuff ... thank you so much!

Chris
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 12, 2016, 10:01:22 PM
Oh - one other thing ...

Apparently, the other mods I've installed HAVE made modifications to these files. They don't seem to be interfering with the code change here -- but, if anyone wants to see the actual files, I'm happy to email them (just in case there is a potential conflict).
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: margarett on March 13, 2016, 07:39:22 AM
Quote from: lemur21 on March 12, 2016, 03:49:39 PM
I was suspicious, because I didn't know why the code included my user name here on the forum (lemur21) -- out of curiosity, why is that?
I needed to create unique text strings, as I can't just create something like
$txt['locked']
It's too generic and it might even overwrite an SMF existing string. Since you requested the code, your username is a great way of making these strings unique :P

Quote from: lemur21 on March 12, 2016, 03:49:39 PM
Also - second question (and this may be the behavior of SMF by itself) -- the 'Sticky" topics now have "Sticky" preceding the topic name, and the entire "headline" is bold. The Poll has "Poll" before the name, but it's not bold. Was that something that changed through this update, or, are Sticky topics always bold by default (and, if so, is there an easy way to make Polls bolded as well?)
That is SMF's default styling
Sticky is bold + different background, locked is italics, poll is just normal. You can change that in Themes/default/css/index.css
(https://www.simplemachines.org/community/index.php?action=dlattach;topic=544016.0;attach=247098;image)

The calendar thing needs to wait. I don't think I ever looked into Calendar's code before :P
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 13, 2016, 11:38:50 AM
That's awesome (re: the text string) -- I still don't understand it; but it's good to know :)

As far as the bolding, I checked the Index.css for the default *and* the theme I have -- and I see where it identifies "Strong" as "bold" - but I can't see where it lists Sticky as strong (or bold), which means I can't see how to make the polls bold, either.

RE: the calendar - I may repost with *just* that question (I think a separate post, identifying the question *in* the headline, might help) .... we'll see :)

Thank you so much for all your help (and, if you can figure out the calendar issue, all the better)!!!!

There's a light at the end of the tunnel, it seems :)
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 13, 2016, 11:44:58 AM
Actually - here's a question ...

Does the bolding actually take place in the index.css file? Or in MessageIndex?

I ask - because apparently, I changed this years ago (maybe?) - and the changes I made were in MessageIndex:    http://www.simplemachines.org/community/index.php?topic=119633

I'll do that again; but before I do, I wanted to make sure things hadn't changed.
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 15, 2016, 08:42:34 PM
Apparently, it *is* in messageindex.template
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 19, 2016, 12:30:35 PM
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!
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 19, 2016, 12:46:41 PM
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>';
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: live627 on March 19, 2016, 08:54:53 PM
QuoteHowever, there is NOTHING like that in the BoardIndex file ... this is the last thing I need ... any insights? :)
Open ../Sources/Subs-Calendar.php

Find:

foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy)
$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];



Change to:

foreach ($cached_data['birthdays'][$loop_date] as $index => &$birthday)
{
$birthday['is_today'] = $loop_date === $today['date'];
$birthday['date'] = $loop_date;
}


UNTESTED!!!
Title: Re: Two things I had in 1.1.xx -- labeling topics and sorting calendar items
Post by: lemur21 on March 19, 2016, 09:16:36 PM
This did it!!!!

I do now have dates with the birthdays ... thank you so much!!!!

I had already figured out the events (but not the birthdays) -- earlier today.

But, in my tinkering, I may have broken one other thing .... 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 here's the thread I'll keep updating:

http://www.simplemachines.org/community/index.php?topic=544345.0

Thank you so much, once again!