Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi all,
I'm tryng to figure out how to modify the list_view of a template depending on the number of cloned pages.
Code: Select all
<cms:template title='Dev Dummy' clonable='1' executable='0' order='15' parent='dev' dynamic_folders='1'>
    <cms:set page_count="<cms:pages count_only='1' show_unpublished='1' show_future_entries='1' />" scope='global' />
   
    <cms:if page_count lt '5'>
        <cms:config_list_view>
            <cms:html><h1>less than</h1></cms:html>
        </cms:config_list_view>
    <cms:else />
        <cms:config_list_view>
            <cms:html><h1>less than</h1></cms:html>
        </cms:config_list_view>
    </cms:if>
   
    <cms:editable type='richtext' name='content'>Hello</cms:editable>
</cms:template>

the above only gets the updated page_count when the template is refreshed.
i've scoured the forums/docs but have been unable to find anything, although it often turns out that i'm just rubbish at searching.
Also wondered if the following might work
Code: Select all
    <cms:if "<cms:if k_route_name eq 'list_view'><cms:show "<cms:pages count_only='1' show_unpublished='1' show_future_entries='1' />" ></cms:if>" lt '5'>
        <cms:config_list_view>
            <cms:html><h1>less than</h1></cms:html>
        </cms:config_list_view>
    <cms:else />
        <cms:config_list_view>
            <cms:html><h1>less than</h1></cms:html>
        </cms:config_list_view>
    </cms:if>
 

but couldn't even figure out how to nest the tags properly (tho i run into this quite often!)
I'm sure I'm just missing something obvious, but missing it I am.
Any pointers appreciated.
Hi,

Perhaps the following would help -
Code: Select all
<cms:config_list_view>
    <cms:html>
        <cms:set my_page_count="<cms:pages count_only='1' show_unpublished='1' show_future_entries='1' />" scope='global' />

        <cms:if my_page_count lt '5'>
            <h1><cms:show my_page_count /> is less than 5</h1>
        </cms:if>   
    </cms:html>
</cms:config_list_view>
Hi KK,
thanks for the quick reply, but i don't think so in this case.
I should have explained better before, but I'm using trendomans dataTables in backend, and wanted:
1 - check that the number of pages is less than n and if so load the dataTables code which is done through the config_list_view.
2 - to set the page_limit on the config_list_view to the current total_pages

Code: Select all
    <cms:if total_pages lte dt_max_pages >
        <cms:config_list_view exclude="default-page-for-<cms:embed 'functions/string/get-clean-url.html' url=k_template_name ></cms:embed>" searchable='0' limit=total_pages >
            <cms:smart_embed 'datatables/list-view' />
        </cms:config_list_view>
    <cms:else />
        // do normal couch listing
    </cms:if>


Unless I'm missing something in your code.
Hi KK,
Yup, I was missing something. the obvious actually :)

Have everything working now:
Code: Select all
<cms:if k_template_is_clonable = '1' >
    <cms:set dt_tot = "<cms:pages count_only='1' show_unpublished='1' show_future_entries='1' />" scope='local' />
    <cms:set dt_max = "<cms:get_field 'global_contact_form_dt_max_pages' masterpage='globals_sa.php' />" scope='local' />

    <cms:style>
        <cms:set dt_tot = "<cms:pages count_only='1' show_unpublished='1' show_future_entries='1' />" scope='global' />
        <cms:set dt_max = "<cms:get_field 'global_contact_form_dt_max_pages' masterpage='globals_sa.php' />" scope='global' />
        <cms:smart_embed 'datatables/styles' debug='0'/>
        <cms:if dt_tot gt dt_max >
            <cms:smart_embed 'datatables/styles/_overrides' debug='0'/>
        </cms:if>
    </cms:style>
    <cms:html>
        <cms:if dt_tot le dt_max >
            <cms:embed 'datatables/list-view/html/common.html' />
            <cms:smart_embed 'datatables/list-view/html' />
        </cms:if>
    </cms:html>
    <cms:script>
        <cms:set dt_tot = "<cms:pages count_only='1' show_unpublished='1' show_future_entries='1' />" scope='global' />
        <cms:set dt_max = "<cms:get_field 'global_contact_form_dt_max_pages' masterpage='globals_sa.php' />" scope='global' />
        <cms:if dt_tot le dt_max >
            <cms:smart_embed 'datatables/scripts' />
        </cms:if>
    </cms:script>


I had to repeat the dt_tot & dt_max statements in the script tag as they didn't seem to carry over like between the style and html tags.
But it seems to work. So thank you once more for your help.

The one thing I am stuck on now is getting the right limit into the config_list_view tag.
I need to be able to set it to the total number of pages if it is less than the page limit otherwise set it to a global limit otherwise set it to 15.

at the moment i have:
Code: Select all
<cms:template title='Contact Form Data' clonable='1' executable='0' order='15' parent='data' dynamic_folders='1'>
    <cms:no_cache />
    <cms:set dt_tot = "<cms:pages count_only='1' show_unpublished='1' show_future_entries='1' />" scope='local' />
    <cms:set dt_max = "<cms:get_field 'global_contact_form_dt_max_pages' masterpage='globals_sa.php' />" scope='local' />
    <cms:set dt_lim = "<cms:get_field 'list_limit' masterpage='globals_sa.php' />" scope='global' />

    <cms:if dt_tot le dt_max>
        <cms:set dt_lim = dt_tot scope='global' />
    <cms:else />
        <cms:if dt_lim >
        <cms:else />
            <cms:set dt_lim = '15' scope='global'/>
        </cms:if>
    </cms:if>
    <!-- LIST VIEW    -->
    <cms:config_list_view exclude="default-page-for-<cms:embed 'functions/string/get-clean-url.html' url=k_template_name ></cms:embed>" searchable='0' limit=dt_lim order='1110' >
        <cms:smart_embed 'datatables/list-view' />
    </cms:config_list_view>


Obviously, this doesn't work unless the template is refreshed.
I've been going around in circles (doing a lot of that lately).
Any clues?
cheers, gwil
4 posts Page 1 of 1