[Typo3-dev] Attaching files to a calendar event - and list them to download - How?

Marlies C mc at mcuniverse.com
Tue Jun 14 00:14:12 CEST 2005


"Marlies C" <mc at mcuniverse.com> wrote in message 
news:mailman.1.1118691899.11460.typo3-dev at lists.netfielders.de...
> We are working on creating an add-on extension to Calendar to list files 
> associated with calendar events. So far so good, no problem we can get the 
> files, but now, how can we make it that only the files associated with 
> that event/record in a folder are linked and not the other files in the 
> folder?
>
> Could anybody give us some ideas as to how we could go about this?
>

Hi Again,

This is how we solved the problem:

#Setup.txt

dox = USER
dox.userFunc = tx_calendar_pi1->showDox


#template
DOX < plugin.tx_calendar_pi1.dox

# pi1/class.tx_calendar_pi1.php
function showDox($content, $conf) {
$this->initdefaults($content, $conf);
//if ($this->getCurrentView() != CALENDAR_VIEW_EVENT) { return false; }
$eid = $this->piVars['f1'];

//if we have no eid, we are not on the event page
if (strlen($eid == 0)) {return false;}
$files = array();
$file_list = "";
$upl_dir = "./uploads/tx_dfcalendarfile/";
$query = "SELECT tx_dfcalendarfile_event_files FROM tx_calendar_item
WHERE uid = ".$eid;
$res = mysql(TYPO3_db, $query);
if (mysql_num_rows($res) === 0) {
return "No files attached.";
} else {
$row = mysql_fetch_assoc($res);
if (strlen($row['tx_dfcalendarfile_event_files']) == 0) {return "No
files attached.";}
$files = explode(",", $row['tx_dfcalendarfile_event_files']);
foreach($files as $key=>$value) {
$file_list.= '<div id="event_document"><a
href="'.$upl_dir.$value.'">'.$value.'</a></div>';
}
return $file_list;
}


}

Marlies & Reuven
www.enomaly.com








More information about the TYPO3-dev mailing list