Created
May 15, 2013 13:30
-
-
Save sniffdk/5583994 to your computer and use it in GitHub Desktop.
Sort document type in the dropdownlist when creating a new node in Umbraco.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* From web.config or some other config place */ | |
<add key="CreateContentSortOrder" value="Content page,Section page,some other page type name" /> | |
/* In /umbraco/create/content.ascx - put the code in the bottom */ | |
<% | |
var createContentSortOrder = ConfigurationManager.AppSettings["CreateContentSortOrder"]; | |
if (!String.IsNullOrWhiteSpace(createContentSortOrder)) | |
{ %> | |
<script type="text/javascript"> | |
$(function () { | |
var sortOrder = <%= "['" + createContentSortOrder.Replace(",", "','") + "']" %>; | |
var $select = $('select'); | |
var $options = $('option', $select); | |
$(sortOrder).each(function (i, o) { | |
$options.each(function () { | |
var $option = $(this); | |
if ($option.text() === o) { | |
$option.appendTo($select); | |
} | |
}); | |
}); | |
$options.each(function () { | |
var $option = $(this); | |
if (sortOrder.indexOf($option.text()) == -1) { | |
$option.appendTo($select); | |
} | |
}); | |
$select.val($('option:first-child', $select)); | |
}); | |
</script> | |
<% } %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment