TinyPortal

Development => Support => Topic started by: Bixby on January 23, 2023, 01:30:33 AM

Title: Looking for assistance to Get Calendar Events to list in a block
Post by: Bixby on January 23, 2023, 01:30:33 AM
Hello:

Thank you for the TP Mod and even more, thank you for providing a forum to request support.

I am spinning up a new site and it is my first time using SMF 2.1 and first time also for using TinyPortal. I have managed a couple of SMF sites for a few years so I am comfortable with the concepts and admin of SMF in general.

Link to my site: https://community.pwyf.ca/
SMF version: SMF 2.1.3
TP version: 2.2.2
Default Forum Language: English
Theme name and version: Bend 1.2.3
Browser Name and Version: Chrome
Mods installed:
Simple Audio Video Embedder 7.0.1
SMF Gallery Lite 7.1
TinyPortal 2.2.2
Related Error messages: n/a

What I would like to do is have Calendar Events show up as a list showing the name of the event and the date. These events would be clickable to take the member/guest to the actual event posting. Events are 90% of the content and purpose foe the site.

I should also point out that I am not technical and do not know/understand coding.

Thank you very much in advance.
Matt
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: Bixby on January 23, 2023, 01:31:58 AM
As an additional semi related request, Can I get a list of recent topics instead of recent posts to show in a block? The Recent Topics seems to present me with a list of recent posts instead.
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: @rjen on January 23, 2023, 12:46:17 PM
Quote from: Bixby on January 23, 2023, 01:30:33 AM

What I would like to do is have Calendar Events show up as a list showing the name of the event and the date. These events would be clickable to take the member/guest to the actual event posting. Events are 90% of the content and purpose foe the site.

Create a php block where you want it and paste the below code into it...


$result = ssi_todaysEvents('array');

if (!empty($result))
{
   echo '<div class="smalltext"><a href="../index.php?board=28.0"><b>Upcoming events:</b></a></div>';
   echo '<div class="supersmalltext">';
   foreach ($result as $event)
      {
      $temp = explode('-', $event['date']);
      $event['date'] = $temp[2] . '-' . $temp[1] . '-' . $temp[0];
    echo '<a href="' . $event['href'] . '">' . $event['date'] . ' : ' . $event['title'] . '</a><br />';
      }
   echo '</div>';
}
else
{
      echo '<div class="supersmalltext">No upcoming events.<br /><br /></div>';
  }
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: @rjen on January 23, 2023, 12:49:12 PM
Quote from: Bixby on January 23, 2023, 01:31:58 AM
As an additional semi related request, Can I get a list of recent topics instead of recent posts to show in a block? The Recent Topics seems to present me with a list of recent posts instead.

If you are using the standard recent topics block, that will most definately show the topics and not the posts: recent posts would show the topics twice if the recent posts are in the same topics.
Recent topics shows the topics most recently posted to, not most recently created...

Why do you think it is showing incorrect?
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: Bixby on January 23, 2023, 05:18:42 PM
Thank you for the quick reply. I added the code snippet and nothing is appearing. The events I currently have posted occur in March, do I need to post slightly different code to show all upcoming events for the next 180 days?

Regarding the Recent Topics, the latest replies are taking precedence so it is showing recent posts instead of recent topics.

Example at: https://community.pwyf.ca/index.php
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: @rjen on January 23, 2023, 05:24:19 PM
I forgot:  check you calendar settings for this setting; if too low it will not show events
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: @rjen on January 23, 2023, 05:25:41 PM
Recent topics is functioning the way it is intended on your site as far as I can see
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: Bixby on January 23, 2023, 05:32:23 PM
Quote from: @rjen on January 23, 2023, 05:24:19 PM
I forgot:  check you calendar settings for this setting; if too low it will not show events

Amazing. Thank You!

I am disappointed in myself that I missed that earlier. :)

Any chance this can show date in YYYY-MM-DD format?
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: Bixby on January 23, 2023, 05:34:03 PM
Quote from: @rjen on January 23, 2023, 05:25:41 PM
Recent topics is functioning the way it is intended on your site as far as I can see

I thought Recent TOPIC would show new recent TOPICS and link to the first post in the topic. What I am seeing is that recent replies (Posts) are being shown / linked to instead.
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: @rjen on January 23, 2023, 05:35:53 PM
You will need to switch these date field around...

      $temp = explode('-', $event['date']);
      $event['date'] = $temp[2] . '-' . $temp[1] . '-' . $temp[0];

Temp0 is year
Temp1 is month
Temp2 is day

And replace the separators '-'  to whatever
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: @rjen on January 23, 2023, 05:37:47 PM
Quote from: @rjen on January 23, 2023, 12:49:12 PM
Recent topics shows the topics most recently posted to, not most recently created...

Why do you think it is showing incorrect?

And indeed, it links to the latest post added to that topic
Title: Re: Looking for assistance to Get Calendar Events to list in a block
Post by: Bixby on January 23, 2023, 05:40:59 PM
Quote from: @rjen on January 23, 2023, 05:35:53 PM
You will need to switch these date field around...

      $temp = explode('-', $event['date']);
      $event['date'] = $temp[2] . '-' . $temp[1] . '-' . $temp[0];

Temp0 is year
Temp1 is month
Temp2 is day

And replace the separators '-'  to whatever

Brilliant!!

Thank you so much. The quick and efficient support is greatly appreciated.