Closed (duplicate)
Project:
Minutes
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
8 May 2007 at 00:16 UTC
Updated:
15 May 2008 at 11:56 UTC
With the code below, I am able to publish my minutes with an alias such 'minutes/2007/04/05' - the date values come from the event associated with the minutes.
Index: modules/minutes/minutes.module
===================================================================
--- modules/minutes/minutes.module (revision 4022)
+++ modules/minutes/minutes.module (working copy)
@@ -676,3 +676,59 @@
function minutes_views_default_views() {
}
+/**
+* Implement pathauto hook to define minutes node placeholders
+*
+* @param string $op
+* @param object $node
+*/
+function minutes_pathauto_node($op, $node = NULL) {
+
+ switch ($op) {
+ case 'placeholders':
+ return array(
+ t('[minutes_eventyyyy]') => t('The year of an event associated with a minutes node.'),
+ t('[minutes_eventmm]') => t('The month of an event associated with a minutes node.'),
+ t('[minutes_eventdd]') => t('The day of an event associated with a minutes node.'),
+ );
+ break;
+
+ case 'values':
+ $results = array();
+ switch ($node->type) {
+ case 'minutes':
+ $results[t('[minutes_eventyyyy]')] = _minutes_date($node, 'minutes_eventyyyy');
+ $results[t('[minutes_eventmm]')] = _minutes_date($node, 'minutes_eventmm');
+ $results[t('[minutes_eventdd]')] = _minutes_date($node, 'minutes_eventdd');
+ return $results;
+ break;
+ }
+ break;
+ }
+}
+
+/**
+* Substitute minutes pathauto placeholders with values from event
+*
+* @param object $node Minutes node
+* @param string $placeholder Placeholder to substitute
+* @return string Partial date value
+*/
+function _minutes_date($node, $placeholder) {
+
+ $event = node_load($node->event_id);
+
+ switch($placeholder) {
+ case 'minutes_eventyyyy':
+ return date('Y', $event->event_start);
+ break;
+
+ case 'minutes_eventmm':
+ return date('m', $event->event_start);
+ break;
+
+ case 'minutes_eventdd':
+ return date('d', $event->event_start);
+ break;
+ }
+}
Comments
Comment #1
mightyiam commentedSo one can't control the minute's paths with pathauto? Or is this a way to be able to use the associated event date?
Comment #2
jonathan_hunt commentedSorry, missed your post. You can control minute's paths with pathauto like any other node. This exposes the associated event data; IMHO this makes for more useful URLs. It needs to be updated to work with the new pathauto API and token module though.
Comment #3
mightyiam commentedOh i get it. Excellent.
Comment #4
jonathan_hunt commentedI've updated my placeholders code to work with Pathauto 2.x and Token module:
Comment #5
robertgarrigos commentedI've added a patch with token support before I saw your code. As It's best to provide patches, I included your code in my patch: http://drupal.org/node/258804