Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
Hello all,
Am confusing myself with this one now...

I have a template 'globals_sa.php', which has a radio button with two values.
Code: Select all
    <!-- MISC settings -->
    <cms:set g_order = '100000' 'global' />
    <cms:editable order="<cms:show g_order />" type='group' name='grp_misc' collapsed='1' label='Misc. settings' >
        <!-- Allow menu sorting  -->
        <cms:editable order= '100' type="radio" name="global_allow_menu_sort" label="Allow menu sorting" desc="select to enable USER menu sorting" opt_values='No=0 | Yes=1' />
    </cms:editable>

I access this value in another template 'index.php' to allow user sorting of nested_pages or not.
Code: Select all
<cms:set g_allow_edit = '0' scope='global'/>
<cms:set g_allow_edit = "<cms:get_field 'global_allow_menu_sort' masterpage='globals_sa.php' />"  scope='global'/>

Code: Select all
    <!-- LIST VIEW    -->
    <cms:if g_allow_edit ne '1' >
        <cms:config_list_view>
            <cms:field 'k_selector_checkbox'/>
            <cms:field 'k_page_title' />
            <cms:field 'k_comments_count' />
            <cms:field 'k_actions' />
        </cms:config_list_view>
    </cms:if>

When i access the second template the value returned by get_field from globals_sa.php is always the setting as it was when I last accessed index.php as super-admin NOT the current value as saved in 'globals_sa.php'.

Is there anyway to get the value of g_allow_edit to be current?
As always, any help greatly appreciated.
The <cms:config_list_view> tag (and all other tags that are meant to be placed within the <cms:template> block) fire only when the template is accessed by the super-admin from the front-end. That should explain the behavior you are getting

This should also explain that this technique is not suitable for your use-case. The only way I see your use-case being handled is by injecting some custom JS in the list-view to hide/show the columns at run-time
@KK thanks for the swift reply.

That would explain it then. I'll find another way.


I'm having an issue with user_access_level in the backend

https://www.couchcms.com/forum/viewtopic.php?f=4&t=12269#p34039

is that caused by the same functionality?

Thankyou again for your time,
gwil
is that caused by the same functionality?
That is possible - you did not mention in the post exactly where the dump code was placed. If it is in a tag somewhere within cms:template, then yes that could be the reason as the code would execute only for super-admin on the front-end.
Yes, looking at it it is the same problem. i'll pop answer at bottom of that thread.

Sooooo...
If I want to control the display of things in backend based on user_access_level or values in another template i can inject js into the <config_list_view>/<config_form_view> sections but how can the js get the values?

Sorry if obvious &/or i'm missing something.
Please review the section on <config_list_view> at viewtopic.php?f=5&t=10241
The injected JS is dynamic in the sense that any Couch tags contained therein will get executed to produce the final JS code - you may check for user level to get the right output,
Yes, sorry, was waiting to be allowed to post again.
Was being a bit dumb :oops: , all makes sense now.
thankyou once again :D .
cheers,
gwil
JS solutions can only hide columns, but not remove them from generated source HTML. In some cases there is sensitive information contained in hidden columns meant to be visible by super-admin only. In such cases, there must be coded and registered a custom list-view which will generate different HTML each time based on who's logged in.
@trendoman, I agree.
If simply hiding columns does not suffice, one may use either custom-views or template override to serve different HTML based on who is logged in.
@trendoman, @KK Couldn't agree more.
Luckily in this case simply hiding will suffice.
Cheers,
gwil
10 posts Page 1 of 1