XF 2.1 Conditional admin menu options

Syndrogo

Member
I'm currently coding an addon to add more options to nodes. I would like to hide part of the menu if the addon is not enabled. I have tried using just the "if" commands but it doesn't actively update when enabling/disabling. Is it even possible?
 
Anything added by your add-on shouldn't be shown when the add-on is not enabled. Make sure all template modifications and other items are associated with your add-on.
 
Yes, that is true but I have an enable selector in the menu for nodes because every node won't be utilizing the addon. This is where I want to use a collapsible menu. When the menu option is disabled the other menu items disappear. When enable they reappear.
 
Ok so the first problem is figured out the second issue is that we have to click Save first then it will show the new options. How can we have the checkbox act like an ajax checkbox that will auto load the new options once someone enables the new checkbox?
 
@kick this is what I did, not sure if I did this correct but it's still giving me
Code:
Option tag contains unexpected child element
error. Here is what I did, maybe you will be able to see where I went wrong.

HTML:
<hr class="formRowSep" />
    <xf:checkboxrow data-hide="true">
        <xf:option name="gt_ag_agegate" value="{$forum.gt_ag_agegate}" label="{{ phrase('gt_agegate_title') }}">{{ phrase('gt_agegate_enable') }}</xf:option>
        <xf:dependent>
                <xf:numberboxrow name="gt_ag_agelimit" value="{$forum.gt_ag_agelimit}" min="0" max="100"
                    label="{{ phrase('gt_agegate_min') }}"
                    explain="{{ phrase('gt_agegate_min_ex') }}" />
        </xf:dependent>
    </xf:checkboxrow>
                <xf:checkboxrow date-hide="true">
                    <xf:option name="gt_ag_mature_o" value="{$forum.gt_ag_mature_o}" label="{{ phrase('gt_agegate_m_warn') }}">{{ phrase('gt_agegate_enable') }}</xf:option>
                    <xf:dependent>
                    <xf:numberboxrow name="gt_ag_mature_time_o" value="{$forum.gt_ag_mature_time_o}" min="0" max="365"
                        label="{{ phrase('gt_agegate_m_time_days') }}"
                        explain="{{ phrase('gt_agegate_m_time_ex') }}" />
                    </xf:dependent>
                </xf:checkboxrow>
                <xf:checkboxrow data-hide="true">
                    <xf:option name="gt_ag_banner" value="{$forum.gt_ag_banner}" label="{{ phrase('gt_agegate_banner') }}">{{ phrase('gt_agegate_enable') }}</xf:option>
                <xf:dependent>
                    <xf:textboxrow name="gt_ag_banner_icon" value="{$forum.gt_ag_banner_icon}" hint="{{ phrase('gt_agegate_banner_icon_h') }}"
                        maxlength="120"
                        label="{{ phrase('gt_agegate_banner_icon_l') }}" />
                    <xf:textarearow name="gt_ag_banner_text" value="{$forum.gt_ag_banner_text}" autosize="true"
                        label="{{ phrase('gt_agegate_banner_text_l') }}" maxlength="1000"
                        hint="{{ phrase('gt_agegate_banner_text_h') }}" />
                </xf:dependent>
    </xf:checkboxrow>
        <hr class="formRowSep" />
                $0
 
@Mythotical, Naturally a mistake. This parameter applies only to the option.
HTML:
<hr class="formRowSep" />
    <xf:checkboxrow>
        <xf:option name="gt_ag_agegate" data-hide="true" value="{$forum.gt_ag_agegate}" label="{{ phrase('gt_agegate_title') }}">{{ phrase('gt_agegate_enable') }}</xf:option>
        <xf:dependent>
                <xf:numberboxrow name="gt_ag_agelimit" value="{$forum.gt_ag_agelimit}" min="0" max="100"
                    label="{{ phrase('gt_agegate_min') }}"
                    explain="{{ phrase('gt_agegate_min_ex') }}" />
        </xf:dependent>
    </xf:checkboxrow>
                <xf:checkboxrow>
                    <xf:option date-hide="true" name="gt_ag_mature_o" value="{$forum.gt_ag_mature_o}" label="{{ phrase('gt_agegate_m_warn') }}">{{ phrase('gt_agegate_enable') }}</xf:option>
                    <xf:dependent>
                    <xf:numberboxrow name="gt_ag_mature_time_o" value="{$forum.gt_ag_mature_time_o}" min="0" max="365"
                        label="{{ phrase('gt_agegate_m_time_days') }}"
                        explain="{{ phrase('gt_agegate_m_time_ex') }}" />
                    </xf:dependent>
                </xf:checkboxrow>
                <xf:checkboxrow>
                    <xf:option data-hide="true" name="gt_ag_banner" value="{$forum.gt_ag_banner}" label="{{ phrase('gt_agegate_banner') }}">{{ phrase('gt_agegate_enable') }}</xf:option>
                <xf:dependent>
                    <xf:textboxrow name="gt_ag_banner_icon" value="{$forum.gt_ag_banner_icon}" hint="{{ phrase('gt_agegate_banner_icon_h') }}"
                        maxlength="120"
                        label="{{ phrase('gt_agegate_banner_icon_l') }}" />
                    <xf:textarearow name="gt_ag_banner_text" value="{$forum.gt_ag_banner_text}" autosize="true"
                        label="{{ phrase('gt_agegate_banner_text_l') }}" maxlength="1000"
                        hint="{{ phrase('gt_agegate_banner_text_h') }}" />
                </xf:dependent>
    </xf:checkboxrow>
        <hr class="formRowSep" />
                $0
 
Thanks @kick I now get checkboxrow tag contains an unexpected child element.

New code
HTML:
<hr class="formRowSep" />
    <xf:checkboxrow>
        <xf:option data-hide="true" name="gt_ag_agegate" selected="$forum.gt_ag_agegate" label="{{ phrase('gt_agegate_enable') }}" hint="{{ phrase('gt_agegate_title') }}" />
        <xf:dependent>
                <xf:numberboxrow name="gt_ag_agelimit" value="{$forum.gt_ag_agelimit}" min="0" max="100"
                    label="{{ phrase('gt_agegate_min') }}"
                    explain="{{ phrase('gt_agegate_min_ex') }}" />
        </xf:dependent>
    </xf:checkboxrow>
    <xf:checkboxrow>
        <xf:option data-hide="true" name="gt_ag_mature_o" selected="$forum.gt_ag_mature_o" label="{{ phrase('gt_agegate_enable') }}" hint="{{ phrase('gt_agegate_m_warn') }}" />
            <xf:dependent>
                <xf:numberboxrow name="gt_ag_mature_time_o" value="{$forum.gt_ag_mature_time_o}" min="0" max="365"
                    label="{{ phrase('gt_agegate_m_time_days') }}"
                    explain="{{ phrase('gt_agegate_m_time_ex') }}" />
            </xf:dependent>
    </xf:checkboxrow>
    <xf:checkboxrow>
        <xf:option data-hide="true" name="gt_ag_banner" selected="$forum.gt_ag_banner" label="{{ phrase('gt_agegate_enable') }}" hint="{{ phrase('gt_agegate_banner') }}" />
            <xf:dependent>
                <xf:textboxrow name="gt_ag_banner_icon" value="{$forum.gt_ag_banner_icon}" hint="{{ phrase('gt_agegate_banner_icon_h') }}"
                    maxlength="120"
                    label="{{ phrase('gt_agegate_banner_icon_l') }}" />
                <xf:textarearow name="gt_ag_banner_text" value="{$forum.gt_ag_banner_text}" autosize="true"
                    label="{{ phrase('gt_agegate_banner_text_l') }}" maxlength="1000"
                    hint="{{ phrase('gt_agegate_banner_text_h') }}" />
            </xf:dependent>
    </xf:checkboxrow>
<hr class="formRowSep" />
$0
 
Check this:
HTML:
<hr class="formRowSep" />
    <xf:checkboxrow>
        <xf:option data-hide="true" name="gt_ag_agegate" selected="$forum.gt_ag_agegate" label="{{ phrase('gt_agegate_enable') }}" hint="{{ phrase('gt_agegate_title') }}">
            <xf:dependent>
                <xf:numberboxrow name="gt_ag_agelimit" value="{$forum.gt_ag_agelimit}" min="0" max="100"
                    label="{{ phrase('gt_agegate_min') }}"
                    explain="{{ phrase('gt_agegate_min_ex') }}" />
            </xf:dependent>
        </xf:option>
    </xf:checkboxrow>
    <xf:checkboxrow>
        <xf:option data-hide="true" name="gt_ag_mature_o" selected="$forum.gt_ag_mature_o" label="{{ phrase('gt_agegate_enable') }}" hint="{{ phrase('gt_agegate_m_warn') }}">
            <xf:dependent>
                <xf:numberboxrow name="gt_ag_mature_time_o" value="{$forum.gt_ag_mature_time_o}" min="0" max="365"
                    label="{{ phrase('gt_agegate_m_time_days') }}"
                    explain="{{ phrase('gt_agegate_m_time_ex') }}" />
            </xf:dependent>
        </xf:option>
    </xf:checkboxrow>
    <xf:checkboxrow>
        <xf:option data-hide="true" name="gt_ag_banner" selected="$forum.gt_ag_banner" label="{{ phrase('gt_agegate_enable') }}" hint="{{ phrase('gt_agegate_banner') }}">
            <xf:dependent>
                <xf:textboxrow name="gt_ag_banner_icon" value="{$forum.gt_ag_banner_icon}" hint="{{ phrase('gt_agegate_banner_icon_h') }}"
                    maxlength="120"
                    label="{{ phrase('gt_agegate_banner_icon_l') }}" />
                <xf:textarearow name="gt_ag_banner_text" value="{$forum.gt_ag_banner_text}" autosize="true"
                    label="{{ phrase('gt_agegate_banner_text_l') }}" maxlength="1000"
                    hint="{{ phrase('gt_agegate_banner_text_h') }}" />
            </xf:dependent>
        </xf:option>
    </xf:checkboxrow>
<hr class="formRowSep" />
$0
 
Back
Top Bottom