コード例 #1
0
ファイル: template.php プロジェクト: bikramth19/wordpress
function proma_preprocess_page(&$vars)
{
    // main menu
    $custom_main_menu = _custom_main_menu_render_superfish();
    if (!empty($custom_main_menu['content'])) {
        $vars['navigation'] = $custom_main_menu['content'];
    }
    if (arg(0) == 'node' && arg(1)) {
        $nid = arg(1);
        $node = node_load($nid);
        switch ($node->type) {
            case 'blog':
                $vars['title'] = t('Blog');
                break;
            case 'portfolio':
                $vars['title'] = t('Portfolio');
                break;
        }
    }
    //search block form
    $seach_block_form = drupal_get_form('search_block_form');
    $seach_block_form['#id'] = 'searchform';
    $seach_block_form['search_block_form']['#id'] = 's2';
    $seach_block_form['search_block_form']['#attributes']['placeholder'] = t('Search...');
    $vars['seach_block_form'] = drupal_render($seach_block_form);
    //sidebar
    $sidebar_region_details = _proma_get_multiple_regions(array('sidebar_'));
    $sidebar_regions = $sidebar_region_details['sidebar_'];
    // Count the results:
    $sidebar_count = count($sidebar_regions);
    // Start from zero:
    $sidebar_total_width = 0;
    // If there are any sidebars, loop through all the columns:
    if ($sidebar_count > 0) {
        foreach ($sidebar_regions as $key => $name) {
            // If this sidebar actually has content:
            if (count($vars['page'][$key]) > 0) {
                // Find out how big it's supposed to be:
                $column_width_setting = (int) theme_get_setting(sprintf(PROMA_THEME_SETTINGS_COLUMN_VARIABLE_PATTERN, $key));
                // Make it available to the page template:
                $vars[sprintf(PROMA_PAGE_TEMPLATE_VARIABLE_PATTERN, $key)] = $column_width_setting;
                // Add the width of this sidebar to the total sidebar width:
                $sidebar_total_width += $column_width_setting;
            }
        }
    }
    $vars[sprintf(PROMA_PAGE_TEMPLATE_VARIABLE_PATTERN, 'content')] = PROMA_GRID_COLUMNS - $sidebar_total_width;
}
コード例 #2
0
function perspective_preprocess_page(&$vars)
{
    // main menu
    $custom_main_menu = _custom_main_menu_render_superfish();
    if (!empty($custom_main_menu['content'])) {
        $vars['navigation'] = $custom_main_menu['content'];
    }
    // overide node title with content type
    if (arg(0) == 'node' && arg(1)) {
        $nid = arg(1);
        $node = node_load($nid);
        switch ($node->type) {
            case 'blog':
                $vars['title'] = t('Blog');
                break;
            case 'portfolio':
                $vars['title'] = t('Portfolio');
                break;
        }
    }
    //search block form
    $seach_block_form = drupal_get_form('search_block_form');
    $seach_block_form['#id'] = 'searchform';
    $seach_block_form['search_block_form']['#id'] = 's';
    $seach_block_form['search_block_form']['#attributes']['placeholder'] = t('Search...');
    $vars['seach_block_form'] = drupal_render($seach_block_form);
    // footer copyright message
    $vars['perspective_footer_copyright'] = theme_get_setting('perspective_footer_copyright', 'perspective');
    // footer social links
    $vars['perspective_footer_social_links'] = theme_get_setting('perspective_footer_social_links', 'perspective');
    //banner slider
    if (variable_get('theme_perspective_first_install', TRUE)) {
        include_once 'theme-settings.php';
        _perspective_install();
    }
    if (theme_get_setting('perspective_homepage_type') == 'slider') {
        $banners = perspective_show_banners();
        $vars['slider'] = perspective_banners_markup($banners);
    } else {
        $vars['slider'] = perspective_hompage_get_video();
    }
    //sidebar
    $sidebar_region_details = _perspective_get_multiple_regions(array('sidebar_'));
    $sidebar_regions = $sidebar_region_details['sidebar_'];
    // Count the results:
    $sidebar_count = count($sidebar_regions);
    // Start from zero:
    $sidebar_total_width = 0;
    // If there are any sidebars, loop through all the columns:
    if ($sidebar_count > 0) {
        foreach ($sidebar_regions as $key => $name) {
            // If this sidebar actually has content:
            if (count($vars['page'][$key]) > 0) {
                // Find out how big it's supposed to be:
                $column_width_setting = (int) theme_get_setting(sprintf(PERSPECTIVE_THEME_SETTINGS_COLUMN_VARIABLE_PATTERN, $key));
                // Make it available to the page template:
                $vars[sprintf(PERSPECTIVE_PAGE_TEMPLATE_VARIABLE_PATTERN, $key)] = $column_width_setting;
                // Add the width of this sidebar to the total sidebar width:
                $sidebar_total_width += $column_width_setting;
            }
        }
    }
    $vars[sprintf(PERSPECTIVE_PAGE_TEMPLATE_VARIABLE_PATTERN, 'content')] = PERSPECTIVE_GRID_COLUMNS - $sidebar_total_width;
}