Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
Hi there,

I'm using a dynamic select field to let users change the blog's folder that is displayed. It seems to work fine, the only issue is that the current folder isn't selected when I'm on that specific page. Is there a way to let the current folder be the selected option?

This is my HTML:

Code: Select all
<select id="dynamic_select">
    <option value="<cms:link masterpage='news.php' />">All</option>

    <cms:folders masterpage='news.php' orderby='weight'>
        <option value="<cms:show k_folder_link/>"><cms:show k_folder_title /></option>
    </cms:folders>
</select>


And script:

Code: Select all
$(function(){
    // bind change event to select
    $('#dynamic_select').on('change', function () {
        var url = $(this).val(); // get selected value
        if (url) { // require a URL
           window.location = url; // redirect
        }
        return false;
    });
});


Thank you in advance :)
Found a solution...

Code: Select all
<select id="dynamic_select">
    <option value="<cms:link masterpage='news.php' />">All</option>

    <cms:folders masterpage='news.php' orderby='weight'>
        <option value="<cms:show k_folder_link/>" <cms:if k_page_link=k_folder_link>selected</cms:if>><cms:show k_folder_title /></option>
    </cms:folders>
</select>


Added <cms:if k_page_link=k_folder_link>selected</cms:if>
2 posts Page 1 of 1