Projet

Général

Profil

Paste
Télécharger (3,18 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / mayo / layouts / core / three_col_grail / three_col_grail.inc @ d7f58da2

1
<?php
2

    
3
/**
4
 * @file
5
 * Implimentation of a Page Layout Plugin.
6
 *
7
 * Usage:
8
 * The naming convetion here is very important, the function name must match the
9
 * method name and the array key. Do not add anything else to it. In the layout
10
 * function simply append "_layout", this gets called when the user submits the
11
 * theme settings form.
12
 *
13
 */
14
function three_col_grail() {                     // - function name must be identical to the method and the array key.
15
  $page_layout['three_col_grail'] = array(       // - array key.
16
    'title'     => t('Three Column Holy Grail'), // - title, needed for the UI.
17
    'method'    => 'three_col_grail',            // - method, this must match the function name and the key, definitly not optional!
18
    'type'      => 'page_layout',                // - type, tell the system this is a page_layout, not optional!
19
    'admin css' => 'three_col_grail.admin.css',  // - admin css, optional.
20
    'device_groups' => array(                    // - device_groups, define which device groups this layout can work with, can be one or more of:
21
      'bigscreen',                               //   'bigscreen', 'tablet_landscape', 'tablet_portrait', 'smalltouch_landscape'
22
      'tablet_landscape',                        //   What you enter here will dictate the device groups it shows for in theme settings.
23
     ),
24
  );
25

    
26
  return $page_layout;
27
}
28

    
29
/**
30
 * CSS Builder for the three_col_grail layout.
31
 * This does not have to be anything like this, but it must return a string of
32
 * CSS, thats about it, and only has 3 bits of data to work with that come
33
 * from the theme settings (what the user entered in the UI), of course you can
34
 * just make up your own data if that works for  your layout, see the
35
 * one_col_stack for such an implimentation.
36
 *
37
 * Remember, if you are building a sub-theme you have full control over the
38
 * theme settings form via your sub-themes hook_form_system_theme_settings_alter()
39
 * in theme-settings.php
40
 *
41
 * @param $sidebar_first, an arbitary numeric value.
42
 * @param $sidebar_second, an arbitary numeric value.
43
 * @param $sidebar_unit, a value unit, one of px, em or %.
44

    
45
 */
46
function three_col_grail_layout($sidebar_first, $sidebar_second, $sidebar_unit) {
47

    
48
  // Set variables for language direction. In thoery a layout plugin could
49
  // be RTL compatible.
50
  $left = 'left';
51
  $right = 'right';
52

    
53
  // Set vars for your sidebars, this can be very different, and entirely
54
  // depends on your layout.
55
  $sidebar_second = $sidebar_second . $sidebar_unit;
56
  $sidebar_first  = $sidebar_first . $sidebar_unit;
57

    
58
  // Define margins/negative margins if required, AT is a content source
59
  // ordered layout and uses a negative margin layout system.
60
  $push_right = $sidebar_second;
61
  $push_left  = $sidebar_first;
62
  $pull_right = $sidebar_second;
63

    
64
  $styles = <<<EOF
65
.two-sidebars #content .section {margin-$left: $push_left; margin-$right: $push_right}
66
.one-sidebar #content .section {margin-$left: $push_left;}
67
#sidebar-first .section {margin-left: 0; margin-right: 10px;}
68
#sidebar-second .section {margin-right: 0; margin-left: 10px;}
69
#sidebar-first {width: $sidebar_first; margin-$left: -100%}
70
#sidebar-second {width: $sidebar_second; margin-$left: -$pull_right}
71
EOF;
72

    
73
  return $styles;
74
}