function _media_gallery_prevent_unwanted_pathauto_aliases in Media Gallery 7.2
Same name and namespace in other branches
- 7 media_gallery.module \_media_gallery_prevent_unwanted_pathauto_aliases()
Hack to prevent Pathauto from generating unwanted taxonomy aliases.
This function can be called before allowing the Pathauto module to act on a saved term for the taxonomy vocabulary used for media galleries. It prevents Pathauto from generating an alias for the term based on the generic Pathauto taxonomy alias settings (i.e., an alias will only be generated if the site is specifically configured to have aliases generated for the vocabulary, not for taxonomy terms in general).
The reason we want to do this is so that the URL alias people save on the media gallery settings page will actually work.
If a $term object is not provided, then this function will always act; if one is provided, then it will only act if the term corresponds to the media gallery default collection.
Call _media_gallery_allow_all_pathauto_aliases() after the term is saved to resume normal Pathauto behavior for the rest of the page request.
3 calls to _media_gallery_prevent_unwanted_pathauto_aliases()
- media_gallery_create_taxonomy_term in ./
media_gallery.install - Helper function to create required taxonomy term.
- media_gallery_taxonomy_term_insert in ./
media_gallery.module - Implements hook_taxonomy_term_insert().
- media_gallery_taxonomy_term_update in ./
media_gallery.module - Implements hook_taxonomy_term_update().
File
- ./
media_gallery.module, line 1766
Code
function _media_gallery_prevent_unwanted_pathauto_aliases($term = NULL) {
if (!isset($term) || $term->tid == variable_get('media_gallery_default_collection_tid')) {
if (isset($GLOBALS['conf']['pathauto_taxonomy_pattern'])) {
$GLOBALS['conf']['media_gallery_original_pathauto_taxonomy_pattern'] = $GLOBALS['conf']['pathauto_taxonomy_pattern'];
}
$GLOBALS['conf']['pathauto_taxonomy_pattern'] = '';
}
}