/[drupal]/contributions/themes/box_grey_smarty/smartytemplate.php
ViewVC logotype

Contents of /contributions/themes/box_grey_smarty/smartytemplate.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Sat Jan 21 06:57:41 2006 UTC (3 years, 10 months ago) by tclineks
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-4-7
File MIME type: text/x-php
synching with box_grey (maily css overhaul and image.module themeing).
Improving image.module theme to serve as an example.
1 <?php
2 // $Id$
3
4 /**
5 * The techniques used in this file are by no means the best practices.
6 * Most of what is done here (between this file and the image_gallery.tpl)
7 * could be much more simple and streamlined but I have intentially employed
8 * many aspects of the Smarty<>Drupal integration system to provide examples.
9 * Enjoy!
10 */
11
12 /**
13 * overload theme('image_gallery') to call our image_gallery.tpl
14 */
15 function smarty_image_gallery($galleries, $images) {
16 return _smarty_callback('image_gallery', array('galleries' => $galleries, 'images' => $images));
17 }
18
19 /**
20 * define functions to register for use in your template file.
21 *
22 * return an associative array of
23 * ((function name in template) => (actual function name)) pairs.
24 * also excepts a single key as if key and value were the same.
25 */
26 function smarty_register_functions(){
27 return array(
28 'gen_gallery_link' => 'smarty_gen_gallery_link',
29 'gen_image_link' => 'smarty_gen_image_link',
30 'format_plural' => 'wrap_format_plural',
31 'add_image_gallery_pager',
32 'assign_is_empty',
33 );
34 }
35
36 /**
37 * called from image_gallery.tpl
38 *
39 * separated to beautify image_gallery.tpl
40 */
41 function smarty_gen_gallery_link($params, &$smarty) {
42 $gallery = $params['gallery'];
43 $result = l(image_display($gallery->latest, 'thumbnail'), 'image/tid/'.$gallery->tid, array(), NULL, NULL, FALSE, TRUE);
44 $result .= check_markup($gallery->description);
45 return $result;
46 }
47
48 function smarty_gen_image_link($params, &$smarty) {
49 $image = &$params['image'];
50 $result = l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE);
51 return $result;
52 }
53
54 function add_image_gallery_pager() {
55 if ($pager = theme('pager', NULL, variable_get('image_images_per_page', 6), 0)) {
56 return $pager;
57 }
58 }
59
60 function assign_is_empty($params, &$smarty) {
61 $images = $params['images'];
62 $galleries = $galleries['images'];
63 $is_empty = count($images) + count($galleries) == 0;
64 $smarty->assign('is_empty', $is_empty);
65 }
66
67 /**
68 * example for generic existing function wrap
69 */
70 function wrap_format_plural($params, &$smarty) {
71 return call_user_func_array('format_plural', $params);
72 }
73 ?>

  ViewVC Help
Powered by ViewVC 1.1.2