<#if siteId?has_content || parentId?has_content>
<ul>
    <#list page.list as a>
        <li<#if a.childIds?has_content> _src="cmsCategory/lookupBySiteId?siteId=${siteId!}&currentCategoryId=${currentCategoryId!}&parentId=${a.id}&field=${(field?url)!'categoryId'}"</#if>>
            <a tname="categoryIds" tvalue="${a.id}"<#if currentCategoryId?has_content && a.id?string=currentCategoryId> disabled="disabled" class="disabled exclude-translate"<#else> class="exclude-translate"</#if>>${a.name!}</a>
        </li>
    <#else>
        <li><a><@t.page 'empty_directory'/></a></li>
    </#list>
</ul>
<#else>
<form action="cmsContent/distribute?callbackType=closeCurrent" method="post" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
    <input type="hidden" name="id" value="${id!}"/>
    <input type="hidden" name="_csrf" value="<@tools.csrfToken admin=true/>"/>
    <div class="pageFormContent" layoutH>
        <ul class="tree treeFolder treeCheck excludeParent">
            <#if site.parentId?has_content>
                <li _src="cmsCategory/lookupBySiteId?siteId=${site.parentId}&currentCategoryId=${currentCategoryId!}&field=${field!'categoryId'}">
                    <a href="javascript:;" class="exclude-translate"><@sys.site id=site.parentId>${object.name!}</@sys.site></a>
                </li>
                <@sys.siteList parentId=site.parentId pageSize=500>
                    <#list page.list as a>
                        <li _src="cmsCategory/lookupBySiteId?siteId=${a.id}&currentCategoryId=${currentCategoryId!}&field=${field!'categoryId'}">
                            <a href="javascript:;" class="exclude-translate">${a.name!}<#if site.id=a.id>[<@t.page 'site.current_site'/>]</#if></a>
                        </li>
                    </#list>
                </@sys.siteList>
            <#else>
                <@sys.siteList pageSize=500>
                    <#list page.list as a>
                        <li _src="cmsCategory/lookupBySiteId?siteId=${a.id}&currentCategoryId=${currentCategoryId!}&field=${field!'categoryId'}">
                            <a href="javascript:;" class="exclude-translate">${a.name!}<#if site.id=a.id>[<@t.page 'site.current_site'/>]</#if></a>
                        </li>
                    </#list>
                </@sys.siteList>
                <@sys.siteList parentId=site.id pageSize=500>
                    <#list page.list as a>
                        <li _src="cmsCategory/lookupBySiteId?siteId=${a.id}&currentCategoryId=${currentCategoryId!}&field=${field!'categoryId'}">
                            <a href="javascript:;" class="exclude-translate">${a.name!}</a>
                        </li>
                    </#list>
                </@sys.siteList>
            </#if>
        </ul>
    </div>
    <div class="formBar">
        <ul>
            <li><button type="submit" class="buttonActive" title="ctrl+s"><@t.page 'button.distribute'/></button></li>
            <li><button type="button" class="button close"><@t.page 'button.close'/></button></li>
        </ul>
    </div>
</form>
</#if>