i needed the same functionality. it's not perfectly finished yet and i'm not a good coder but the following works for me.
1.) add a new field to the cal_events table called 'article', type: INT.
2.) add the following code in the main.functions.php underneath the function showCategories:
Code: Select all
function showArticles($loc_art) {
$result = mysql_query("SELECT * FROM ".DB_PREPEND."phpwcms_article WHERE article_public = 1 AND article_deleted = 0 ")
or die("There was an error<br /> " . mysql_error() . "<hr />");
$value_loc .= "<select name=\"article\">";
while ($row = mysql_fetch_array($result)) {
$value_loc .= "<option name=\"article\"";
if ($row[article_id]==$loc_art) {
$value_loc .= " selected";
}
$value_loc .= " value=\"$row[article_id]\">$row[article_title]</option>\n";
}
$value_loc .= "</select>\n";
return $value_loc;
}
3.) in calendar.event.forms.php add underneath
Code: Select all
<tr>
<th align="right"><?php echo $BL['be_cal']['forms']['location']; ?>:</th>
<td align="left"><input type="text" id="location" name="location" value="<?php echo stripslashes($values['location']); ?>" /></td>
</tr>
the following code:
Code: Select all
<tr>
<th align="right">Article:</th>
<td align="left"> <?php echo showArticles($values['article']); ?></td>
</tr>
4.) in calendar.classes.php look for the function 'make_events' (around line 262). in this function you add after
Code: Select all
$event = file_get_contents(PHPWCMS_ROOT."/include/inc_module/mod_calendar/inc_front/templates/".$template);
the following code:
Code: Select all
$articleresult = mysql_query("SELECT * FROM ".DB_PREPEND."phpwcms_article WHERE article_id = " . $row['article'] . " LIMIT 1")
or die("There was an error<br /> " . mysql_error());
while ($articlerow = mysql_fetch_array($articleresult, MYSQL_ASSOC)) {
$art_id=$articlerow["article_id"];
$art_cid=$articlerow["article_cid"];
}
mysql_free_result($articleresult);
$eventlink = "<a href=\"index.php?id=" . $art_cid . "," . $art_id . ",0,0,1,0\">more</a>";
$event = str_replace("{EVENTLINK}", $eventlink , $event);
5.) on line 383 in the function 'showEvents' you have to change:
Code: Select all
$sql = "SELECT setid, events.id, title, category, name, description, approved, date FROM "
to
Code: Select all
$sql = "SELECT setid, events.id, title, category, name, description, approved, date, article FROM "
6.) on line 697 in the function 'insert_single_event' you have to change:
Code: Select all
$sql .= "(date, span, time, title, category, price, location, description, extrainfo, approved, setid, userId) ";
to
Code: Select all
$sql .= "(date, span, time, title, category, price, location, description, extrainfo, approved, setid, userId, article) ";
and on line 710 change
to
Code: Select all
$sql .= "0, ";
$sql .= "$values[article])";
7.) on line 743 in the function 'update_event' you have to change:
to
Code: Select all
$extra_sql .= "setid = $setid, ";
$extra_sql .= "article = $values[article] ";
8.) on line 767 in the function 'update_event_set' you have to change:
Code: Select all
$extra_sql .= "setid = $values[setid] ";
to
Code: Select all
$extra_sql .= "setid = $values[setid], ";
$extra_sql .= "article = $values[article] ";
9.) for showing the article-link in your event list you have to use the replacement tag {EVENTLINK} within your event template.
the articlelink also can be put directly in the eventtitle-link.