modification: "subcatify" becomes optionnal. Enabled by default, easy to
revert to previous display. git-svn-id: http://piwigo.org/svn/trunk@1132 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
d700a59172
commit
a892e6abf9
5 changed files with 206 additions and 89 deletions
|
|
@ -60,32 +60,92 @@ $query.= '
|
|||
;';
|
||||
$result = pwg_query( $query );
|
||||
|
||||
// template thumbnail initialization
|
||||
if (mysql_num_rows($result) > 0)
|
||||
if ($conf['subcatify'])
|
||||
{
|
||||
$template->assign_block_vars('categories', array());
|
||||
}
|
||||
|
||||
// for each category, we have to search a recent picture to display and
|
||||
// the name to display
|
||||
while ( $row = mysql_fetch_array( $result ) )
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'categories.category',
|
||||
$template->set_filenames(
|
||||
array(
|
||||
'SRC' => get_thumbnail_src($row['path'], @$row['tn_ext']),
|
||||
'ALT' => $row['file'],
|
||||
'TITLE' => $lang['hint_category'],
|
||||
|
||||
'URL' => make_index_url(
|
||||
array(
|
||||
'category' => $row['category_id'],
|
||||
)
|
||||
),
|
||||
'NAME' => get_cat_display_name_cache($row['uppercats'], null, false),
|
||||
'NB_IMAGES' => $row['nb_images'],
|
||||
'DESCRIPTION' => @$row['comment'],
|
||||
'mainpage_categories' => 'mainpage_categories.tpl',
|
||||
)
|
||||
);
|
||||
|
||||
// template thumbnail initialization
|
||||
if (mysql_num_rows($result) > 0)
|
||||
{
|
||||
$template->assign_block_vars('categories', array());
|
||||
}
|
||||
|
||||
// for each category, we have to search a recent picture to display and
|
||||
// the name to display
|
||||
while ( $row = mysql_fetch_array( $result ) )
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'categories.category',
|
||||
array(
|
||||
'SRC' => get_thumbnail_src($row['path'], @$row['tn_ext']),
|
||||
'ALT' => $row['file'],
|
||||
'TITLE' => $lang['hint_category'],
|
||||
|
||||
'URL' => make_index_url(
|
||||
array(
|
||||
'category' => $row['category_id'],
|
||||
)
|
||||
),
|
||||
'NAME' => get_cat_display_name_cache($row['uppercats'], null, false),
|
||||
'NB_IMAGES' => $row['nb_images'],
|
||||
'DESCRIPTION' => @$row['comment'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$template->assign_var_from_handle('CATEGORIES', 'mainpage_categories');
|
||||
}
|
||||
else
|
||||
{
|
||||
// template thumbnail initialization
|
||||
if (mysql_num_rows($result) > 0)
|
||||
{
|
||||
$template->assign_block_vars('thumbnails', array());
|
||||
// first line
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
// current row displayed
|
||||
$row_number = 0;
|
||||
}
|
||||
|
||||
$old_level_separator = $conf['level_separator'];
|
||||
$conf['level_separator'] = '<br />';
|
||||
// for each category, we have to search a recent picture to display and
|
||||
// the name to display
|
||||
while ( $row = mysql_fetch_array( $result ) )
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'thumbnails.line.thumbnail',
|
||||
array(
|
||||
'IMAGE' => get_thumbnail_src($row['path'], @$row['tn_ext']),
|
||||
'IMAGE_ALT' => $row['file'],
|
||||
'IMAGE_TITLE' => $lang['hint_category'],
|
||||
|
||||
'U_IMG_LINK' => make_index_url(
|
||||
array(
|
||||
'category' => $row['category_id'],
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$template->assign_block_vars(
|
||||
'thumbnails.line.thumbnail.category_name',
|
||||
array(
|
||||
'NAME' => get_cat_display_name_cache($row['uppercats'], null, false),
|
||||
)
|
||||
);
|
||||
|
||||
// create a new line ?
|
||||
if (++$row_number == $user['nb_image_line'])
|
||||
{
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
$row_number = 0;
|
||||
}
|
||||
}
|
||||
$conf['level_separator'] = $old_level_separator;
|
||||
}
|
||||
?>
|
||||
|
|
@ -43,7 +43,8 @@ $result = pwg_query($query);
|
|||
|
||||
// $conf['allow_random_representative']
|
||||
|
||||
$cat_thumbnails = array();
|
||||
$categories = array();
|
||||
$image_ids = array();
|
||||
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
|
|
@ -91,72 +92,123 @@ SELECT representative_picture_id
|
|||
}
|
||||
|
||||
$comment = null;
|
||||
if ( isset($row['comment']) )
|
||||
if (isset($row['comment']))
|
||||
{
|
||||
$comment = strip_tags( $row['comment'] );
|
||||
$comment = strip_tags($row['comment']);
|
||||
}
|
||||
|
||||
if (isset($image_id))
|
||||
{
|
||||
array_push(
|
||||
$cat_thumbnails,
|
||||
$categories,
|
||||
array(
|
||||
'category' => $row['id'],
|
||||
'picture' => $image_id,
|
||||
'name' => $row['name'],
|
||||
'date_last' => @$row['date_last'],
|
||||
'comment' => $comment,
|
||||
'nb_images' => $row['nb_images'],
|
||||
'category' => $row['id'],
|
||||
'picture' => $image_id,
|
||||
'name' => $row['name'],
|
||||
'date_last' => @$row['date_last'],
|
||||
'comment' => $comment,
|
||||
'nb_images' => $row['nb_images'],
|
||||
)
|
||||
);
|
||||
|
||||
array_push($image_ids, $image_id);
|
||||
}
|
||||
|
||||
unset($image_id);
|
||||
}
|
||||
|
||||
if (count($cat_thumbnails) > 0)
|
||||
if (count($image_ids) > 0)
|
||||
{
|
||||
$images = array();
|
||||
|
||||
foreach ($cat_thumbnails as $item)
|
||||
{
|
||||
$images[$item['picture']] = '';
|
||||
}
|
||||
$thumbnail_src_of = array();
|
||||
|
||||
$query = '
|
||||
SELECT id, path, tn_ext
|
||||
FROM '.IMAGES_TABLE.'
|
||||
WHERE id IN ('.implode(',', array_keys($images)).')
|
||||
WHERE id IN ('.implode(',', $image_ids).')
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
$images[$row['id']] = get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
$thumbnail_src_of[$row['id']] =
|
||||
get_thumbnail_src($row['path'], @$row['tn_ext']);
|
||||
}
|
||||
|
||||
$template->assign_block_vars('categories', array());
|
||||
|
||||
foreach ($cat_thumbnails as $item)
|
||||
|
||||
if ($conf['subcatify'])
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'categories.category',
|
||||
$template->set_filenames(
|
||||
array(
|
||||
'SRC' => $images[$item['picture']],
|
||||
'ALT' => $item['name'],
|
||||
'TITLE' => $lang['hint_category'],
|
||||
'ICON' => get_icon(@$item['date_last']),
|
||||
|
||||
'URL' => make_index_url(
|
||||
array(
|
||||
'category' => $item['category'],
|
||||
'cat_name' => $item['name'],
|
||||
)
|
||||
),
|
||||
'NAME' => $item['name'],
|
||||
'NB_IMAGES' => $item['nb_images'],
|
||||
'DESCRIPTION' => @$item['comment'],
|
||||
'mainpage_categories' => 'mainpage_categories.tpl',
|
||||
)
|
||||
);
|
||||
|
||||
$template->assign_block_vars('categories', array());
|
||||
|
||||
foreach ($categories as $category)
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'categories.category',
|
||||
array(
|
||||
'SRC' => $thumbnail_src_of[ $category['picture'] ],
|
||||
'ALT' => $category['name'],
|
||||
'TITLE' => $lang['hint_category'],
|
||||
'ICON' => get_icon(@$category['date_last']),
|
||||
|
||||
'URL' => make_index_url(
|
||||
array(
|
||||
'category' => $category['category'],
|
||||
'cat_name' => $category['name'],
|
||||
)
|
||||
),
|
||||
'NAME' => $category['name'],
|
||||
'NB_IMAGES' => $category['nb_images'],
|
||||
'DESCRIPTION' => @$category['comment'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$template->assign_var_from_handle('CATEGORIES', 'mainpage_categories');
|
||||
}
|
||||
else
|
||||
{
|
||||
$template->assign_block_vars('thumbnails', array());
|
||||
// first line
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
// current row displayed
|
||||
$row_number = 0;
|
||||
|
||||
foreach ($categories as $category)
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'thumbnails.line.thumbnail',
|
||||
array(
|
||||
'IMAGE' => $thumbnail_src_of[ $category['picture'] ],
|
||||
'IMAGE_ALT' => $category['name'],
|
||||
'IMAGE_TITLE' => $lang['hint_category'],
|
||||
'IMAGE_TS' => get_icon(@$category['date_last']),
|
||||
|
||||
'U_IMG_LINK' => make_index_url(
|
||||
array(
|
||||
'category' => $category['category'],
|
||||
)
|
||||
),
|
||||
'CLASS' => 'thumbCat',
|
||||
)
|
||||
);
|
||||
|
||||
$template->assign_block_vars(
|
||||
'thumbnails.line.thumbnail.category_name',
|
||||
array(
|
||||
'NAME' => $category['name']
|
||||
)
|
||||
);
|
||||
|
||||
// create a new line ?
|
||||
if (++$row_number == $user['nb_image_line'])
|
||||
{
|
||||
$template->assign_block_vars('thumbnails.line', array());
|
||||
$row_number = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -168,6 +168,10 @@ $conf['show_thumbnail_caption'] = true;
|
|||
// name ?
|
||||
$conf['show_picture_name_on_title'] = true;
|
||||
|
||||
// subcatify: display thumbnails representing a category a different way
|
||||
// than thumbnails representing a picture.
|
||||
$conf['subcatify'] = true;
|
||||
|
||||
// allow_random_representative : do you wish PhpWebGallery to search among
|
||||
// categories elements a new representative at each reload ?
|
||||
//
|
||||
|
|
|
|||
|
|
@ -231,33 +231,7 @@
|
|||
</ul>
|
||||
<!-- END thumbnails -->
|
||||
|
||||
<!-- BEGIN categories -->
|
||||
<ul class="thumbnailCategories">
|
||||
<!-- BEGIN category -->
|
||||
<li>
|
||||
<div class="thumbnailCategory">
|
||||
<div class="illustration">
|
||||
<a href="{categories.category.URL}">
|
||||
<img src="{categories.category.SRC}"
|
||||
alt="{categories.category.ALT}"
|
||||
title="{categories.category.TITLE}">
|
||||
</a>
|
||||
</div>
|
||||
<div class="description">
|
||||
<h3>
|
||||
{categories.category.ICON}
|
||||
<a href="{categories.category.URL}">{categories.category.NAME}</a>
|
||||
</h3>
|
||||
<p>{categories.category.NB_IMAGES} {lang:pictures}</p>
|
||||
<p>{categories.category.DESCRIPTION}</p>
|
||||
</div>
|
||||
<hr class="separation" />
|
||||
</div>
|
||||
</li>
|
||||
<!-- END category -->
|
||||
</ul>
|
||||
<hr class="separation" />
|
||||
<!-- END categories -->
|
||||
{CATEGORIES}
|
||||
|
||||
<!-- BEGIN cat_infos -->
|
||||
<!-- BEGIN navigation -->
|
||||
|
|
|
|||
27
template/yoga/mainpage_categories.tpl
Normal file
27
template/yoga/mainpage_categories.tpl
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<!-- BEGIN categories -->
|
||||
<ul class="thumbnailCategories">
|
||||
<!-- BEGIN category -->
|
||||
<li>
|
||||
<div class="thumbnailCategory">
|
||||
<div class="illustration">
|
||||
<a href="{categories.category.URL}">
|
||||
<img src="{categories.category.SRC}"
|
||||
alt="{categories.category.ALT}"
|
||||
title="{categories.category.TITLE}">
|
||||
</a>
|
||||
</div>
|
||||
<div class="description">
|
||||
<h3>
|
||||
{categories.category.ICON}
|
||||
<a href="{categories.category.URL}">{categories.category.NAME}</a>
|
||||
</h3>
|
||||
<p>{categories.category.NB_IMAGES} {lang:pictures}</p>
|
||||
<p>{categories.category.DESCRIPTION}</p>
|
||||
</div>
|
||||
<hr class="separation" />
|
||||
</div>
|
||||
</li>
|
||||
<!-- END category -->
|
||||
</ul>
|
||||
<hr class="separation" />
|
||||
<!-- END categories -->
|
||||
Loading…
Add table
Add a link
Reference in a new issue