Closed (duplicate)
Project:
Station
Version:
5.x-2.x-dev
Component:
Playlists
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Apr 2008 at 21:33 UTC
Updated:
26 Nov 2008 at 09:14 UTC
Please consider adding Token (for use in pathauto and such) support to playlist, below is the code for the most useful info I saw in $object. Not sure if I really need to pull it out of the array, was having trouble loading 'date' out of $object without invoking date the function, and wasn't sure if it was creation date, playlist date.
/*
* Implementation of hook_token_list()
*/
function station_playlist_token_list($type = 'all') {
if ($type == 'node' || $type == 'all') {
$tokens['node']['station_playlistyyyy'] = t("The year the playlist started.");
$tokens['node']['station_playlistmm'] = t("The two-digit month (01-12) the playlist started.");
$tokens['node']['station_playlistmon'] = t("The three-letter month (jan-dec) the playlist started.");
$tokens['node']['station_playlistdd'] = t("The two-digit day of the month (01-31) the playlist started.");
$tokens['node']['station_playlistday'] = t("The three-letter day of the week (sun-sat) the playlist started.");
$tokens['node']['station_playlistweek'] = t("The week number (1-52) of the year the playlist started.");
$tokens['node']['station_playlistname'] = t("The content author name.");
$tokens['node']['station_playlistprogram_title'] = t("The program title.");
return $tokens;
}
}
/*
* Implementation of hook_token_values()
*/
function station_playlist_token_values($type, $object = NULL) {
if ($type == 'node') {
$station_playlistarray = $object->program_date;
$station_playliststart=$station_playlistarray['year'].'-'.$station_playlistarray['month'].'-'.$station_playlistarray['day'];
if (is_numeric($station_playliststart)) $station_playliststart = (int)$station_playliststart;
elseif (is_string($station_playliststart)) $station_playliststart = strtotime($station_playliststart);
$tokens['station_playlistyyyy'] = date('Y', $station_playliststart);
$tokens['station_playlistmm'] = date('m', $station_playliststart);
$tokens['station_playlistmon'] = date('M', $station_playliststart);
$tokens['station_playlistdd'] = date('d', $station_playliststart);
$tokens['station_playlistday'] = date('D', $station_playliststart);
$tokens['station_playlistweek'] = date('W', $station_playliststart);
$tokens['station_playlistname'] = $object->name;
$tokens['station_playlistprogram_title'] = $object->program_title;
return $tokens;
}
}
thanks!
Comments
Comment #1
drewish commentedthis would need to be committed to the 5.x-2.x branch first and then back ported.
i also think that station_playlist_token_values() should check if $node->type == 'station_playlist' before trying to assign all those tokens or you'll get some notices about unset variables.
Comment #2
drewish commentedAlso, I don't think this one is needed:
$tokens['station_playlistname'] = $object->name;
The token module should handle that one by default.
Comment #3
will kirchheimerThanks, Drewish
I haven't gone through the patch submission process yet, I'll tackle it this week.
Comment #4
drewish commenteddoh... totally forgot this was in here. ended up committing another version of it though.
Comment #5
will kirchheimerCool,
Sorry I didn't submit a patch prior, I haven't had a chance to figure out proper "patch"ing yet.
I have another week 'til I go live, and will switch over to your commit for the token values
-- W
Comment #6
summit commentedSubscribing, greetings, Martijn