SimplePortal
Support => English Support => Topic started 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 :
foreach ($day['events'] as $event)
echo '
<li class="sp_list_indent">', sp_embed_image('event'), ' ', $event['link'], ' </li>';
}
-
Which one is it the "title of subject"? (Sorry, I'm not familiar with that particular block.)
-
Attach :)
-
Not tested at all.
$calendar_data = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
$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;
}
}
foreach ($day['events'] as $event)
echo '
<li class="sp_list_indent">', sp_embed_image('event'), ' ', $event['link'], ' </li>';
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>';
-
Thank you so much for your help.
But it does not seem :(
-
"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
-
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. ;)
-
yep :)
3) it doesn't show anything despite not giving errors,
will you be avaible soon? is there a chance you try it?
-
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:
$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;
}
}
-
thank you for help me :)
but; testing:
3) it doesn't show anything despite not giving errors,
-
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.
-
Unfortunately its only work on local. :(
Sending screen shots with attach;
-
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).
-
portalblocks.php
find :
foreach ($calendar_data['weeks'] as $week)
{
foreach ($week['days'] as $day)
before:
$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