tode_url_outbound_alter improvement (path_alias)
Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
		
							
								
								
									
										19
									
								
								tode.css
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								tode.css
									
									
									
									
									
								
							| @@ -11,22 +11,3 @@ | |||||||
| .tode-add-modal-wrapper .tode-add-modal-links{ | .tode-add-modal-wrapper .tode-add-modal-links{ | ||||||
| 	display:inline-block; | 	display:inline-block; | ||||||
| } | } | ||||||
|  |  | ||||||
| #modalContent{ |  | ||||||
| 		 |  | ||||||
| } |  | ||||||
|  |  | ||||||
| #modalContent div.ctools-modal-content{ |  | ||||||
| 	padding:5px; |  | ||||||
| 	-moz-border-radius: 10px; |  | ||||||
| 		-webkit-border-radius: 10px; |  | ||||||
| 		border-radius: 10px; |  | ||||||
| 		 |  | ||||||
| 	border: 0 solid #999; |  | ||||||
| 	 |  | ||||||
| } |  | ||||||
| #modalContent div.ctools-modal-content .modal-header, |  | ||||||
| #modalContent div.ctools-modal-content .modal-header a, |  | ||||||
| #modalContent div.ctools-modal-content .modal-header span{ |  | ||||||
| 	background-color: transparent; color:#000!important; |  | ||||||
| } |  | ||||||
|   | |||||||
							
								
								
									
										49
									
								
								tode.module
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								tode.module
									
									
									
									
									
								
							| @@ -687,7 +687,7 @@ function tode_entity_add_form_submit($form, &$form_state){ | |||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| function _tode_entity_add_form($js = FALSE, $bundle, $entity) { | function BAD_ONE_tode_entity_add_form($js = FALSE, $bundle, $entity) { | ||||||
| 	// dsm('- - - - tode_entity_add_form'); | 	// dsm('- - - - tode_entity_add_form'); | ||||||
| 	//   dsm($bundle, '$bundle'); | 	//   dsm($bundle, '$bundle'); | ||||||
| 	//   dsm($entity, '$entity'); | 	//   dsm($entity, '$entity'); | ||||||
| @@ -773,7 +773,7 @@ function tode_field_widget_form_alter(&$element, &$form_state, $context) { | |||||||
| 					foreach ($entities as $entity) { | 					foreach ($entities as $entity) { | ||||||
| 						$tode_instance = $type_fields[$entity][$tode['field_name']]; | 						$tode_instance = $type_fields[$entity][$tode['field_name']]; | ||||||
| 						 | 						 | ||||||
| 						$btn = ctools_modal_text_button(t('create a new %s', array('%s'=>$entity)), 'tode/nojs/add/'.$bundle.'/'.$entity.'/'.$tode_instance['label'], t('alt'), "ctools-modal-tode-add-modal") . "\n"; // modal-popup-small | 						$btn = ctools_modal_text_button(t('create a new %s', array('%s'=>$entity)), 'tode/nojs/add/'.$bundle.'/'.$entity.'/'.$tode_instance['label'], t('alt'), "button ctools-modal-tode-add-modal") . "\n"; // modal-popup-small | ||||||
| 						// $btn .= ctools_modal_text_button(t('create new test'), 'tode/nojs/add/node/test', t('alt')); | 						// $btn .= ctools_modal_text_button(t('create new test'), 'tode/nojs/add/node/test', t('alt')); | ||||||
| 					// dsm($btn); | 					// dsm($btn); | ||||||
| 						if($element['#suffix'] == '') | 						if($element['#suffix'] == '') | ||||||
| @@ -808,8 +808,6 @@ function tode_field_widget_form_alter(&$element, &$form_state, $context) { | |||||||
| 			 | 			 | ||||||
| 		  drupal_add_js($js_settings, 'setting'); | 		  drupal_add_js($js_settings, 'setting'); | ||||||
| 			 | 			 | ||||||
| 			 |  | ||||||
| 			 |  | ||||||
| 			$element['#prefix'] = '<div class="tode-add-modal-wrapper">'; | 			$element['#prefix'] = '<div class="tode-add-modal-wrapper">'; | ||||||
| 			$element['#suffix'] .= '</div></div>'; | 			$element['#suffix'] .= '</div></div>'; | ||||||
| 		} | 		} | ||||||
| @@ -947,43 +945,44 @@ function tode_delete_submit($form, &$form_state){ | |||||||
|  * Implements hook_url_outbound_alter(). |  * Implements hook_url_outbound_alter(). | ||||||
|  */ |  */ | ||||||
| function tode_url_outbound_alter(&$path, &$options, $original_path) { | function tode_url_outbound_alter(&$path, &$options, $original_path) { | ||||||
| 	// dsm($path); |  | ||||||
| 	# terms url | 	# terms url | ||||||
| 	if (preg_match('/^taxonomy\/term\/([0-9]*)$/', $path, $matches)) { | 	if(isset($options['entity_type']) && $options['entity_type'] == 'taxonomy_term'){ | ||||||
| 		$term = taxonomy_term_load($matches[1]); | 		// dsm('- - - - tode_url_outbound_alter'); | ||||||
| 		// dsm($term, '$term'); | 		// dsm($path, '$path'); | ||||||
| 		$vocabulary = taxonomy_vocabulary_load($term->vid); | 		// dsm($options, '$options'); | ||||||
| 		// dsm($vocabulary, '$vocabulary'); | 		// dsm($original_path, '$original_path'); | ||||||
|  | 		 | ||||||
|  | 		$term = $options['entity']; | ||||||
|  |  | ||||||
|  | 		if($field = _tode_get_voc_tode_fields_def($term->vocabulary_machine_name)){ | ||||||
|  |  | ||||||
| 		if($field = _tode_get_voc_tode_fields_def($vocabulary->machine_name)){ |  | ||||||
| 			// dsm($field, '$field'); |  | ||||||
| 			// $existing_item = db_query('SELECT * FROM {menu_links} WHERE mlid = :mlid', array('mlid' => $item['mlid']))->fetchAssoc(); |  | ||||||
| 			$sr = $field['storage']['details']['sql']['FIELD_LOAD_CURRENT']; | 			$sr = $field['storage']['details']['sql']['FIELD_LOAD_CURRENT']; | ||||||
| 			foreach ($sr as $table => $column) { | 			foreach ($sr as $table => $column) { | ||||||
| 				$query = db_select($table, 'ft') | 				$query = db_select($table, 'ft'); | ||||||
|  | 				$query->join('node', 'n', 'ft.entity_id = n.nid AND n.language = :language', array(':language' => $options['language']->language)); | ||||||
|  | 				$query | ||||||
| 				  ->fields('ft') | 				  ->fields('ft') | ||||||
| 				  ->condition('ft.'.$column['tid'], $term->tid); | 				  ->condition('ft.'.$column['tid'], $term->tid); | ||||||
| 					 |  | ||||||
| 				$result = $query->execute(); | 				$result = $query->execute(); | ||||||
| 				 |  | ||||||
| 				// $entity = db_query('SELECT * FROM :fieldtabe WHERE :fieldcolumn = %tid', array(':fieldtabe'=>$table, ':fieldcolumn'=>$column['tid'], '%tid'=>$term->tid))->fetchAssoc(); |  | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| 			// dsm($result, '$result'); |  | ||||||
| 			foreach ($result as $entity) { | 			foreach ($result as $node) { | ||||||
| 				// dsm($entity, '$entity'); | 				$new_path = 'node/'.$node->entity_id; | ||||||
| 				$path = 'node/'.$entity->entity_id; | 				if( $new_alias = drupal_get_path_alias($new_path, $options['language']->language) ){ | ||||||
|  | 					$path = $new_alias; | ||||||
|  | 					$original_path = $new_path; | ||||||
|  | 					$options['alias'] = TRUE; | ||||||
|  | 				}else{ | ||||||
|  | 					$path = $new_path; | ||||||
|  | 				} | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| 			 | 			 | ||||||
| 		} | 		} | ||||||
| 			 |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * HELPERS  |  * HELPERS  | ||||||
|  */ |  */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 bachy
					bachy