1

I need to add some top links and sub top links . I altered hook_theme function and created two templates for these code is like this-

function acts_theme() {
    return array(
            'acts_top_links' => array(
                    'variables' => array(
                            'links' => NULL,
                            'activelink' => NULL,
                        ),
                    'template' => 'acts-topmenu',
            ),
            'acts_submenu_links' => array(
                    'variables' => array(
                            'links' => NULL,
                            'activelink' => NULL,
                        ),
                    'template' => 'acts-submenu',
            ),
    );
}
function template_preprocess_acts_top_links(&$variables){
    $toplinks=$variables['links'];
    $activelink=$variables['activelink'];
    $variables['toplinks']=$toplinks;
    $variables['activelink']=$activelink;

}
function template_preprocess_acts_submenu_links(&$variables){
    $toplinks=$variables['links'];
    $activelink=$variables['activelink'];
    $variables['sublinks']=$toplinks;
    $variables['activelink']=$activelink;
}

Now I am using these theme output as-

function acts_display(){
    $build['acts_toplinks'] = array(
            '#theme' => 'acts_top_links',
            '#links' => $toplinks,
            '#activelink'=>'Company Law',
    );
    $build['acts_sublinks'] = array(
            '#theme' => 'acts_submenu_links',
            '#links' => $submenulinks,
            '#activelink'=>'/companylaw/acts',
    );

    $build['acts_table_rows'] = array(
            '#theme' => 'table',
            '#rows' => $rows,
            '#empty' => t('Currently there are no active content'),
    );
return $build;
}

I expect output as - first to show- top links, then sub menu links and then table but output exactly reverse- first I get table,then sub menu links and then top links How can I achieve this?

  • Did you try just adding #weight to the arrays in $build()? – bloke_zero Nov 28 '14 at 9:34
  • Yes, this worked with #weight, Post it as answer, will mark as an correct answer – jyotipawar Nov 28 '14 at 12:55
0

If you add the #weight property to the arrays in $build() then that will allow you to order them e.g.:

$build['acts_table_rows'] = array(
        '#theme' => 'table',
        '#rows' => $rows,
        '#empty' => t('Currently there are no active content'),
        '#weight' => 99,
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.