News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Button on $profile_areas does'nt hide

Started by Jotade29, August 31, 2023, 10:33:21 PM

Previous topic - Next topic

Jotade29

Hello, maybe you remember me from topics on quiz, glossary, forum settings... Just in case you don't remember me, i leave this new question...

Version: 2.0.19

I want to hide a button in $profile_areas, which has the following code

'test' => array(
        'title' => '<img style="vertical-align: middle;" src="' . $settings['images_url'] . '/icons_subprofile/test.png" alt="" /> ' . 'Test',
        'hidden' => $g_row == 0,
    'areas' => array(
        'test_status' => array(
        'label' => '<img style="vertical-align: middle;" src="' . $settings['images_url'] . '/icons_subprofile/test.png" alt="" /> ' . 'Estado de mi test',
        'enabled' => true,
        'custom_url' => $scripturl . '?action=test',   
        'permission' => array(
            'own' => 'profile_view_own',
            'any' => 'profile_identity_any',
        ),
            ),
        'test_settings' => array(
            'label' => '<img style="vertical-align: middle;" src="' . $settings['images_url'] . '/icons_subprofile/test.png" alt="" /> ' . 'Ajustes de test',
            'enabled' => true,
            'custom_url' => $scripturl . '?action=test;sa=settings',   
            'permission' => array(
                'own' => 'profile_view_own',
                'any' => 'profile_identity_any',
            ),
                ),   
        ),
    ),

$g_row is a database query of type count_row. The query is executed perfectly, because in the name of the area i put it to see if it is displayed, and it comes out perfectly, 0, 1, 2, whatever... What i intend to do is hide 'test' in its entirety, with all its areas, if the condition set is not met, and, the areas have the same condition as 'test' only they have an additional condition.

I understand that to show/hide I must use "'hidden' =>," the problem is that it does not take $g_row into account, because it binding it correctly from the database, and the condition that i set for it to hide is met, and it doesn't hide. What am ii doing wrong?

Thank you!!
Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

live627

sections don't use hidden, but rather, enabled

Possible fields:
For Section:
string $title:      Section title.
bool $enabled:      Should section be shown?
array $areas:       Array of areas within this section.
array $permission:  Permission required to access the whole section.

For Areas:
array $permission:  Array of permissions to determine who can access this area.
string $label:      Optional text string for link (Otherwise $txt[$index] will be used)
string $file:       Name of source file required for this area.
string $function:   Function to call when area is selected.
string $custom_url: URL to use for this menu item.
bool $enabled:      Should this area even be accessible?
bool $hidden:       Should this area be visible?
string $select:     If set this item will not be displayed - instead the item indexed here shall be.
array $subsections: Array of subsections from this area.

For Subsections:
string 0:       Text label for this subsection.
array 1:        Array of permissions to check for this subsection.
bool 2:         Is this the default subaction - if not set for any will default to first...
bool enabled:       Bool to say whether this should be enabled or not.
https://github.com/SimpleMachines/SMF/blob/194eae6c3e91f8911d4ced76fa446c1de28c0559/Sources/Subs-Menu.php#L32-L54

Jotade29

Quote from: live627 on September 01, 2023, 03:46:45 PMsections don't use hidden, but rather, enabled

Possible fields:
    For Section:
        string $title:      Section title.
        bool $enabled:      Should section be shown?
        array $areas:       Array of areas within this section.
        array $permission:  Permission required to access the whole section.

    For Areas:
        array $permission:  Array of permissions to determine who can access this area.
        string $label:      Optional text string for link (Otherwise $txt[$index] will be used)
        string $file:       Name of source file required for this area.
        string $function:   Function to call when area is selected.
        string $custom_url: URL to use for this menu item.
        bool $enabled:      Should this area even be accessible?
        bool $hidden:       Should this area be visible?
        string $select:     If set this item will not be displayed - instead the item indexed here shall be.
        array $subsections: Array of subsections from this area.

    For Subsections:
        string 0:       Text label for this subsection.
        array 1:        Array of permissions to check for this subsection.
        bool 2:         Is this the default subaction - if not set for any will default to first...
        bool enabled:       Bool to say whether this should be enabled or not.
https://github.com/SimpleMachines/SMF/blob/194eae6c3e91f8911d4ced76fa446c1de28c0559/Sources/Subs-Menu.php#L32-L54

In v 2.0.19 the comments... :(

Possible fields:
            For Section:
                string $title:        Section title.
                array $areas:        Array of areas within this section.

            For Areas:
                string $label:        Text string that will be used to show the area in the menu.
                string $file:        Optional text string that may contain a file name that's needed for inclusion in order to display the area properly.
                string $custom_url:    Optional href for area.
                string $function:    Function to execute for this section.
                bool $enabled:        Should area be shown? Aquí se ponen las condiciones de es visible sí, en cambio hidden solo para ocultar sin condiciones
                string $sc:        Session check validation to do on save - note without this save will get unset - if set.
                bool $hidden:        Does this not actually appear on the menu?
                bool $password:        Whether to require the user's password in order to save the data in the area.
                array $subsections:    Array of subsections, in order of appearance.
                array $permission:    Array of permissions to determine who can access this area. Should contain arrays $own and $any.

I'll update it...
Thank you very much for the support, Live :)
Quote from: Diego Andrés on August 12, 2023, 02:20:18 AMI'm afraid convincing Jotade to upgrade to SMF 2.1 will require bigger effort than your work sanitizing Unicode characters  :laugh:

Advertisement: