Bạn ghé thăm diễn đàn lần đầu? hãy đăng ký ngay bây giờ để tham gia.
  • Đăng nhập:

Chào mừng bạn đến với ITVNN FORUM - Diễn đàn công nghệ thông tin.

Nếu đây là lần đầu tiên bạn tham gia diễn đàn, xin mời bạn xem phần Hỏi/Ðáp để biết cách dùng diễn đàn. Để có thể tham gia thảo luận bạn phải đăng ký làm thành viên, click vào đây để đăng ký.


  • Partner Area
    • ITVNN HOSTING - Thiết kế website, Cung cấp Domain, Hosting, VPS Việt Nam Anh Hùng - Thông tin truyền thông
kết quả từ 1 tới 1 trên 1
Tăng kích thước phông chữ Giảm kích thước phông chữ
  1. #1
    Dunglx's Avatar

    Trạng thái
    Offline
    Họ tên
    VAV
    Tham gia ngày
    Aug 2010
    Thành viên thứ
    29041
    Đến từ
    Gia lâm
    Giới tính
    Bài gởi
    1,762
    Level: 49 [?]
    Experience: 8,814,185
    Next Level: 10,000,000
    Cảm ơn 597
    Cảm ơn 530 lần / 370 Bài viết

    Default Widget: display random image thumbnail from public albums  

    What it does ?
    This widget displays a thumbnail image, taken randomly from any public albums and adds a "More..." link redirecting to albums.
    Clicking on the thumbnail opens full sized picture in its current album.

    Version history :
    1.0: Initial release
    1.1: Style can now be independant of template modification / Added option to display more than one thumbnail / Added option to define a custom size for the thumbnails.
    1.2: You can now restrict picture fetching to a list of albums / Added fixes to the request.

    Install instructions :
    1- Go in to your AdminCP > vBulletin CMS > Widgets > Create new widget
    2- Choose type 'PHP direct execution'
    3- Give it a name (i.e: Random Picture)
    4- Give it a description (i.e Random picture from public albums)
    5- Save it
    6- Configure it with the following code (copy/paste)
    PHP Code: 
    // Display random images thumbnails taken from any public albums.
    // Author : Sulquendi
    // Version: 1.2

    // -- Widget Configuration -- 
    $use_vB_thumbnail_size     false;
    $use_custom_css         false;
    $twidth                 190;
    $limit                    1;
    $albums_list            "";


    // -- Nothing to configure below this line --
    if ($use_custom_css){
        
    $pthumb     'class="pthumb"';
        
    $pcaption    'class="pcaption"';
        
    $pmore        'class="pmore"';
        
    $pstyle        '';
    }else{
        
    $pthumb     'style="text-align:center;"';
        
    $pcaption    'style="text-align:center;font-style:italic;font-family: Times, serif;margin-bottom:10px;"';
        
    $pmore        'style="text-align:right;display:block;"';
        
    $pstyle        'style="border: 1px solid black;padding:4px;background: white;"';
    }
    if (
    $albums_list!=""$sup_cond "AND alb.albumid IN ($albums_list)"; else $sup_cond ="";
    ob_start();
    require_once(
    DIR '/includes/functions_album.php');
    require_once(
    DIR '/includes/functions_user.php');
    $pic_get vB::$db->query_read("
        SELECT     alb.albumid, att.attachmentid, att.userid, att.caption, att.dateline, att.state, fdt.filesize, IF(fdt.thumbnail_filesize > 0, 1, 0) AS hasthumbnail, fdt.thumbnail_dateline, fdt.thumbnail_width, fdt.thumbnail_height, u.username
        FROM "
    .TABLE_PREFIX."album AS alb
        LEFT JOIN "
    .TABLE_PREFIX."attachment AS att ON alb.albumid = att.contentid
        LEFT JOIN "
    .TABLE_PREFIX."filedata AS fdt ON att.filedataid = fdt.filedataid
        LEFT JOIN "
    .TABLE_PREFIX."user AS u ON att.userid = u.userid
        WHERE alb.state = 'public' AND att.contenttypeid = '8' 
    $sup_cond
        ORDER BY rand(" 
    microtime()*1000000 ") 
       LIMIT 
    $limit");
      
    $output_bits "";
      while(
    $pic vB::$db->fetch_array($pic_get))
      {
        
    $albuminfo fetch_albuminfo($pic[albumid]);
        
    $picture prepare_pictureinfo_thumb($pic$albuminfo);
        if (
    $use_vB_thumbnail_size$size $picture[dimensions]; else $size "width=$twidth";
        
    $output_bits .= "<div $pthumb><a href=\"album.php?{$vbulletin->session->vars['sessionurl']}albumid={$pic[albumid]}&attachmentid={$picture[attachmentid]}\"><img $pstyle src=\"attachment.php?{$vbulletin->session->vars['sessionurl']}attachmentid={$picture[attachmentid]}&thumb=1&d={$picture[thumbnail_dateline]}\" alt=\"{$picture[caption_preview]}\" $size /></a>";
        
    $output_bits .= "</div><div $pcaption>{$picture[caption_preview]} by {$pic[username]}</div>";
      }
    $output_bits .= '<span '.$pmore.'><a href="album.php" alt="To the albums">More...</a></span>';
    $output $output_bits;
    ob_end_clean(); 
    7- There are 5 variables you can edit in this code, to configure the widget behavior :
    PHP Code: 
    $use_vB_thumbnail_size     false;
    $use_custom_css         false;
    $twidth                 190;
    $limit                2;
    $albums_list            "1,2,3"
    $albums_list :
    define a list of albums IDs (coma-separated list) to use, when taking a picture randomly.
    You can also specify only one ID.
    note: if you leave this variable empty, ALL public albums will be used.

    $use_vB_thumbnail_size :
    false = the widget will use $twidth to set up the width of the thumbnail.
    true = default vBulletin thumbnail size will be used.

    $twidth:
    Width of a thumbnail (in pixel.)
    will only be used if $use_vB_thumbnail_size is set to false.

    $limit:
    # of thumbnails you want to display in the widget.

    $use_custom_css
    false = the styling of widget elements will be performed inside the widget itself (using style="" html tag.)
    true = the styling will be performed by CSS, thus a template needs to be manually edited : vbcms.css
    Code: 
    .pthumb {
    	text-align:center;
    }
    .pthumb img {
    	border: 1px solid black;
    	padding:4px;
    	background: white;
    }
    .pcaption {
    	text-align:center;
    	font-style:italic;
    	font-family: "Times New Roman", Times, serif;
    	margin-bottom:10px;
    }
    .pmore {
    	text-align:right;
    	display:block;
    }
    8- Your widget is ready to be added to your CMS with AdminCP > vBulletin CMS > Widgets > Layout Manager
    Hình Kèm Theo Hình Kèm Theo


 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Auto display custom image when link images die in post
    By admin in forum v4.x Modifications
    Trả lời: 0
    Bài mới gởi: 01-03-2014, 10:00 AM
  2. Trả lời: 0
    Bài mới gởi: 28-08-2011, 11:57 AM
  3. Trả lời: 0
    Bài mới gởi: 05-09-2010, 03:45 PM
  4. làm sao để sửa kích thước thumbnail trong album vbb 4.0
    By yun in forum Hỏi đáp & Thảo luận
    Trả lời: 2
    Bài mới gởi: 18-03-2010, 02:01 PM
  5. Trả lời: 0
    Bài mới gởi: 14-03-2010, 01:32 PM

Tags for this Thread

Bookmarks

Quuyền Hạn Của Bạn

  • Bạn không thể tạo chủ đề mới
  • Bạn không thể trả lời bài viết
  • Bạn không thể gửi file đính kèm
  • Bạn không thể chỉnh sửa bài viết
  •