SimplePortal

Support => English Support => Topic started by: Alpay on March 11, 2016, 08:49:00 AM

Title: Title of subject near the events of calendar blog ?
Post by: Alpay on March 11, 2016, 08:49:00 AM
Hello,

How can we put the events of calendar blog near title of subject ?
(Settings : Default board to post events in)

PortalBlocks.php :

Code: [Select]
foreach ($day['events'] as $event)
echo '
<li class="sp_list_indent">', sp_embed_image('event'), ' ', $event['link'], '  </li>';
}
Title: Re: Title of subject near the events of calendar blog ?
Post by: emanuele on March 11, 2016, 02:41:33 PM
Which one is it the "title of subject"? (Sorry, I'm not familiar with that particular block.)
Title: Re: Title of subject near the events of calendar blog ?
Post by: Alpay on March 12, 2016, 11:44:49 AM
Attach :)
Title: Re: Title of subject near the events of calendar blog ?
Post by: emanuele on March 14, 2016, 10:27:09 AM
Not tested at all.
Code: (find) [Select]
$calendar_data = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
Code: (add after) [Select]
$events = array();
foreach ($calendar_data['weeks'] as $week)
{
foreach ($week['days'] as $day)
{
if (!empty($day['events']))
{
$events[] = $day['id'];
}
}
}

$topics = array();
if (!empty($events))
{
$request = $smcFunc['db_query']('', '
SELECT c.id_event, t.id_topic, m.subject
FROM {db_prefix}calendar AS c
LEFT JOIN {db_prefix}topics AS t ON (c.id_topic = t.id_topic)
LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE c.id_event IN ({array_int:events})
LIMIT {int:num_events}',
array(
'events' => $events,
'num_events' => count($events),
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$topics[$row['id_event']] = $row;
}
}

Code: (find) [Select]
foreach ($day['events'] as $event)
echo '
<li class="sp_list_indent">', sp_embed_image('event'), ' ', $event['link'], '  </li>';

Code: (replace with) [Select]
foreach ($day['events'] as $event)
echo '
<li class="sp_list_indent">',
sp_embed_image('event'), ' ', $event['link'],
isset($topics[$event['id']]) ? ' | <a href="' . $scripturl . '?topic=' . $topics[$event['id']]['id_topic'] . '.0">' . $topics[$event['id']]['subject'] . '</a>' : '',
'</li>';
Title: Re: Title of subject near the events of calendar blog ?
Post by: Alpay on March 15, 2016, 05:09:51 AM
Thank you so much for your help.

   But it does not seem :(
Title: Re: Title of subject near the events of calendar blog ?
Post by: ♦ Ninja ZX-10RR ♦ on March 15, 2016, 05:43:49 AM
"It doesn't work" is not an explanation and is not helpful, if you try to explain what happens and what exactly doesn't work then he may be able to fix it ;)

Regards
Title: Re: Title of subject near the events of calendar blog ?
Post by: emanuele on March 15, 2016, 08:40:07 AM
   But it does not seem :(
hmm...
I see at least three possibilities:
1) it gives a syntax error,
2) it give another error,
3) it doesn't show anything despite not giving errors,
4) it shows something but not what you want,
5) it shows what you want, but not the way you want it.
...actually I arrived at 5 possibilities. :P
As I said, I didn't try it (mainly because I don't have at the moment a spare reliable SP install anywhere, most of those I have are either development or modified for some reason), so I have no idea of what it does, some more details would help. ;)
Title: Re: Title of subject near the events of calendar blog ?
Post by: Alpay on March 16, 2016, 07:32:15 AM
yep :)

3) it doesn't show anything despite not giving errors,

will you be avaible soon? is there a chance you try it?
Title: Re: Title of subject near the events of calendar blog ?
Post by: emanuele on March 22, 2016, 12:21:20 PM
With a little change to the code above (that was broken, so I have no idea how it didn't give you an error), works as expected.
The correct code is:
Code: [Select]
$events = array();
foreach ($calendar_data['weeks'] as $week)
{
foreach ($week['days'] as $day)
{
if (!empty($day['events']))
{
foreach ($day['events'] as $ev)
{
$events[] = $ev['id'];
}
}
}
}

$topics = array();
global $smcFunc;
if (!empty($events))
{
$request = $smcFunc['db_query']('', '
SELECT c.id_event, t.id_topic, m.subject
FROM {db_prefix}calendar AS c
LEFT JOIN {db_prefix}topics AS t ON (c.id_topic = t.id_topic)
LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE c.id_event IN ({array_int:events})
LIMIT {int:num_events}',
array(
'events' => $events,
'num_events' => count($events),
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$topics[$row['id_event']] = $row;
}
}
Title: Re: Title of subject near the events of calendar blog ?
Post by: Alpay on March 23, 2016, 01:37:42 PM
thank you for help me :)

but; testing:
3) it doesn't show anything despite not giving errors,
Title: Re: Title of subject near the events of calendar blog ?
Post by: emanuele on March 24, 2016, 06:29:16 AM
Do you have any link I can see it in action?
I wonder if you have clicked on the day you have any event, because AFAIK the text is shown only either on the of an event, or when you click on a day that has an event.
Title: Re: Title of subject near the events of calendar blog ?
Post by: Alpay on March 26, 2016, 04:17:04 PM
Unfortunately its only work on local. :(
Sending screen shots with attach;

Title: Re: Title of subject near the events of calendar blog ?
Post by: emanuele on March 27, 2016, 09:16:08 AM
Well, if it works on your localhost it shall work on your online version as well provided that:
1) you are changing the correct file,
2) you are using the same block.

It may not be the case, but if you are using php 5.5+, the php opcache could cause delays in "taking up" the new version of the file (in certain cases they may be completely missed).
Title: Re: Title of subject near the events of calendar blog ?
Post by: Alpay on March 27, 2016, 11:33:43 AM
portalblocks.php

find :

Code: [Select]
foreach ($calendar_data['weeks'] as $week)
{
foreach ($week['days'] as $day)

before:

Code: [Select]
$events = array();
foreach ($calendar_data['weeks'] as $week)
{
foreach ($week['days'] as $day)
{
if (!empty($day['events']))
{
foreach ($day['events'] as $ev)
{
$events[] = $ev['id'];
}
}
}
}

$topics = array();
global $smcFunc;
if (!empty($events))
{
$request = $smcFunc['db_query']('', '
SELECT c.id_event, t.id_topic, m.subject
FROM {db_prefix}calendar AS c
LEFT JOIN {db_prefix}topics AS t ON (c.id_topic = t.id_topic)
LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE c.id_event IN ({array_int:events})
LIMIT {int:num_events}',
array(
'events' => $events,
'num_events' => count($events),
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$topics[$row['id_event']] = $row;
}
}

it works ^^
thank you very much @emanuele
SimplePortal 2.3.8 © 2008-2024, SimplePortal