Projet

Général

Profil

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

root / drupal7 / sites / all / themes / adaptivetheme / at_core / layouts / core / three_col_grail / three_col_grail.inc @ 74f6bef0

1
<?php
2

    
3
/**
4
 * @file
5
 * Implimentation of a Page Layout Plugin for Adaptivetheme.
6
 *
7
 * This looks like a Panels layout plugin, but its not, its designed to work
8
 * only with AT pluggable layout sytem and provides a "page layout".
9
 *
10
 * This layout provide a standard three column layout. The "grail" refers to
11
 * the holy search for the ideal CSS only layout that occured in the late
12
 * 1990's/early 2000's. Yes, I was around back then and participated in that
13
 * grail quest.
14
 *
15
 * Usage:
16
 * The naming convetion here is very important, the function name must match the
17
 * method name and the array key. Do not add anything else to it. In the layout
18
 * function simply append "_layout", this gets called when the user submits the
19
 * theme settings form.
20
 *
21
 * TODO: allow form #states to be defined (UX issue).
22
 * Template loading is hard and not something I had considered because of one
23
 * simple fact - we need a mobile context to do this, otherwise its an all or
24
 * nothing approach - in otherwords if you change templates you must supply
25
 * an entire set of layout plugins that use this template.
26
 */
27
function three_col_grail() {                     // - function name must be identical to the method and the array key.
28
  $page_layout['three_col_grail'] = array(       // - array key.
29
    'title'     => t('Three Column Holy Grail'), // - title, needed for the UI.
30
    'category'  => t('AT Core layout'),          // - category, this could get used but is currently not, include something but its not critical.
31
    'method'    => 'three_col_grail',            // - method, this must match the function name and the key, definitly not optional!
32
    'type'      => 'page_layout',                // - type, tell the system this is a page_layout, not optional!
33
    'admin css' => 'three_col_grail.admin.css',  // - admin css, optional, in AT Core three_col_grail.admin.css loads all the CSS for all layouts.
34
    'device_groups' => array(                    // - device_groups, define which device groups this layout can work with, can be one or more of:
35
      'bigscreen',                               //   'bigscreen', 'tablet_landscape', 'tablet_portrait', 'smalltouch_landscape'
36
      'tablet_landscape',                        //   What you enter here will dictate the device groups it shows for in theme settings.
37
     ),
38
  );
39

    
40
  return $page_layout;
41
}
42

    
43
/**
44
 * CSS Builder for the three_col_grail layout.
45
 * This does not have to be anything like this, but it must return a string of
46
 * CSS, thats about it, and only has 3 bits of data to work with that come
47
 * from the theme settings (what the user entered in the UI), of course you can
48
 * just make up your own data if that works for  your layout, see the
49
 * one_col_stack for such an implimentation.
50
 *
51
 * Remember, if you are building a sub-theme you have full control over the
52
 * theme settings form via your sub-themes hook_form_system_theme_settings_alter()
53
 * in theme-settings.php
54
 *
55
 * @param $sidebar_first, an arbitary numeric value.
56
 * @param $sidebar_second, an arbitary numeric value.
57
 * @param $sidebar_unit, a value unit, one of px, em or %.
58

    
59
 */
60
function three_col_grail_layout($sidebar_first, $sidebar_second, $sidebar_unit) {
61

    
62
  // Set variables for language direction. In thoery a layout plugin could
63
  // be RTL compatible.
64
  $left = 'left';
65
  $right = 'right';
66

    
67
  // Set vars for your sidebars, this can be very different, and entirely
68
  // depends on your layout.
69
  $sidebar_second = $sidebar_second . $sidebar_unit;
70
  $sidebar_first  = $sidebar_first . $sidebar_unit;
71

    
72
  // Define margins/negative margins if required, AT is a content source
73
  // ordered layout and uses a negative margin layout system.
74
  $push_right = $sidebar_second;
75
  $push_left  = $sidebar_first;
76
  $pull_right = $sidebar_second;
77

    
78
  $styles = <<<EOF
79
#content-column,.content-column,div.sidebar {float: left; clear: none}
80
.two-sidebars .content-inner {margin-$left: $push_left; margin-$right: $push_right}
81
.sidebar-first .content-inner {margin-$left: $push_left; margin-$right: 0}
82
.sidebar-second .content-inner {margin-$right: $push_right; margin-$left: 0}
83
.region-sidebar-first {width: $sidebar_first; margin-$left: -100%}
84
.region-sidebar-second {width: $sidebar_second; margin-$left: -$pull_right}
85
EOF;
86

    
87
  return $styles;
88
}