Thread: Social Group and Album Enhancements - All Albums
View Single Post
  #51  
Old 03-14-2008, 11:41 PM
Spingo Spingo is offline
 
Join Date: Jul 2002
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's not too difficult to customise this add-on to provide User Names with each Album, but as the Author has said, these modiications turn the mod into more of a "product" than simply adding a simple PHP file. I have done the following modifications in order to accomplish this on one of my sites (and the author may feel free to use any of this code to provide this feature if he/she so wishes):

In all_albums.php, change:
PHP Code:
    $albums $db->query_read("
        SELECT album.*,
            picture.pictureid, picture.extension, picture.idhash,
            picture.thumbnail_dateline, picture.thumbnail_width, picture.thumbnail_height,
        FROM " 
TABLE_PREFIX "album AS album
        LEFT JOIN " 
TABLE_PREFIX "picture AS picture ON (album.coverpictureid = picture.pictureid AND picture.thumbnail_filesize > 0)
        WHERE album.state IN ('" 
implode("', '"$state) . "')
        ORDER BY album.lastpicturedate DESC
        LIMIT 
$start$perpage
    "
); 
to:
PHP Code:
    $albums $db->query_read("
        SELECT album.*,
            picture.pictureid, picture.extension, picture.idhash,
            picture.thumbnail_dateline, picture.thumbnail_width, picture.thumbnail_height,
            user.username
        FROM " 
TABLE_PREFIX "album AS album
        LEFT JOIN " 
TABLE_PREFIX "picture AS picture ON (album.coverpictureid = picture.pictureid AND picture.thumbnail_filesize > 0)
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON (album.userid = user.userid)
        WHERE album.state IN ('" 
implode("', '"$state) . "')
        ORDER BY album.lastpicturedate DESC
        LIMIT 
$start$perpage
    "
); 
Next, change:
PHP Code:
            eval('$albumbits .= "' fetch_template('albumbit') . '";'); 
to:
PHP Code:
            eval('$albumbits .= "' fetch_template('all_albumbit') . '";'); 
and then, change:
PHP Code:
    eval('print_output("' fetch_template('album_list') . '");'); 
to:
PHP Code:
    eval('print_output("' fetch_template('all_album_list') . '");'); 
Next, go into Style Manager in the admincp and copy the contents of the albumbit template into a new template and call it all_albumbit. Then copy the contents of the album_list template into a new template called all_album_list. For there, you can edit these two new templates to add a User Name column. For instance, in all_album_list, I have changed:
Code:
<tr>
	<td class="thead">Thumbnail</td>
	<td class="thead" width="80%">$vbphrase[album_title]</td>
	<td class="thead" width="5%" align="center">$vbphrase[pictures]</td>
	<td class="thead" width="15%" nowrap="nowrap">$vbphrase[last_picture]</td>
</tr>
to:
Code:
<tr>
	<td class="thead">Thumbnail</td>
	<td class="thead" width="80%">$vbphrase[album_title]</td>
	<td class="thead">Author</td>
	<td class="thead" width="5%" align="center">$vbphrase[pictures]</td>
	<td class="thead" width="15%" nowrap="nowrap">$vbphrase[last_picture]</td>
</tr>
and in all_albumbit, I have changed:
Code:
		<div class="smallfont">
			$album[description_html]
			<if condition="$show['personalalbum']"><span class="shade">$albumtype</span></if>
		</div>
	</td>
	<td class="alt1" valign="middle" align="center">$album[picturecount]</td>
	<td class="alt2" valign="middle" nowrap="nowrap">
to:
Code:
		<div class="smallfont">
			$album[description_html]
			<if condition="$show['personalalbum']"><span class="shade">$albumtype</span></if>
		</div>
	</td>
	<td class="alt2" valign="middle" align="center">
		$album[username]
	</td>
	<td class="alt1" valign="middle" align="center">$album[picturecount]</td>
	<td class="alt2" valign="middle" nowrap="nowrap">
After some tidying up with the class tags (so as to make the colour alternate as intended, I have a pretty good looking result, as shown in the attachment.

Of course, you could customise the order of the columns if you'd like, or even add avatars to the user name without too much difficulty.

I should say that I whipped this mod up in about 15 minutes - so the usual caveat applies - I take no responsibility if something goes awry and it's possible that the code in all_almbums.php after my modifications could require some additional optimisation (specifically, I have not benchmarked what impact my additional JOIN has on the SQL side of things).

Enjoy.
Attached Images
File Type: jpg gallery_author.jpg (39.0 KB, 0 views)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01089 seconds
  • Memory Usage 1,836KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code
  • (6)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_attachment
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete