Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 11-03-2009, 07:37 PM
AWMGolfer AWMGolfer is offline
 
Join Date: Dec 2007
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Truncating Video Text

I figured I'd ask this in here instead of the mod since it's probably a general answer instead of thread specific. I have tried figuring this out myself and I just can't get it. I use the video mod and the mod that adds random videos to my homepage. All I am looking to do is truncate the video title text. Here is the plugin code:

Code:
if ($vbulletin->products['videodirectory'] AND ($permissions['videodirectorypermissions'] & $vbulletin->bf_ugp_videodirectorypermissions['canview']))
{
   //Require functions_videodirectory.php to fetch thumbnail url
   require_once(DIR . '/includes/functions_videodirectory.php');


   $fh_limit = $vbulletin->options['fh_limit'];
   $vert_horiz = $vbulletin->options['vert_horiz'];
   $charactertotal = $vbulletin->options['charactertotal'];

   //If $fh_limit is equal to 0 then this code will not run
   if ($fh_limit > 0)
   {

          $cats = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "videocategory");

          $allowedcats = array(0);
          while ($cat = $db->fetch_array($cats))
          {
            if (!is_member_of($vbulletin->userinfo, explode(',', $cat['usergroups'])) OR !$cat['active'])
            {
               continue;
            }
                $allowedcats[] = $cat['videocategoryid'];
          }

          switch ($vbulletin->options['vid_order'])
          {
            case 'recent':
              $videos = $db->query_read("
                SELECT video.*, user.*, IF(video.ratingnum > 0, video.ratingtotal / video.ratingnum, 0) AS ratingavg, IF(NOT ISNULL(user.userid), user.username, video.username) AS username
                FROM " . TABLE_PREFIX . "video AS video
                LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = video.userid)
                WHERE video.videocategoryid IN(" . implode(',', $allowedcats) . ")
                ORDER BY dateline DESC
                LIMIT " . $fh_limit . "
            ");
            $title = 'Recent Videos';
            break;
           case 'most_viewed':
             $videos = $db->query_read("
                SELECT video.*, user.*, IF(video.ratingnum > 0, video.ratingtotal / video.ratingnum, 0) AS ratingavg, IF(NOT ISNULL(user.userid), user.username, video.username) AS username
                FROM " . TABLE_PREFIX . "video AS video
                LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = video.userid)
                WHERE video.videocategoryid IN(" . implode(',', $allowedcats) . ") AND video.views > 0
                ORDER BY views DESC
                LIMIT " . $fh_limit . "
            ");
            $title = 'Most Viewed Videos';
            break;
          case 'best_rated':
            $videos = $db->query_read("
                SELECT video.*, IF(video.ratingnum > 0, video.ratingtotal / video.ratingnum, 0) AS ratingavg
                FROM " . TABLE_PREFIX . "video AS video
                WHERE video.videocategoryid IN(" . implode(',', $allowedcats) . ")
                ORDER BY ratingavg DESC, ratingnum DESC
                LIMIT " . $fh_limit . "
            ");
            $title = 'Top Rated Videos';
            break;
          default:
            $videos = $db->query_read("
                SELECT video.*, user.*, IF(video.ratingnum > 0, video.ratingtotal / video.ratingnum, 0) AS ratingavg, IF(NOT ISNULL(user.userid), user.username, video.username) AS username
                FROM " . TABLE_PREFIX . "video AS video
                LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = video.userid)
                WHERE video.videocategoryid IN(" . implode(',', $allowedcats) . ")
                ORDER BY RAND() DESC
                LIMIT " . $fh_limit . "
            ");
            $title = 'Random Videos';
          }


         if ($vbulletin->options['video_forumlist'] == 0)
         {

          if ($db->num_rows($videos))
          {
             while ($video = $db->fetch_array($videos))
             {
                $bgclass = exec_switch_bg();
                fetch_videothumbnail($video);

                $video['url'] = construct_video_url($video);

                        if ($vert_horiz == 0)
                        {
                       eval('$fhlist .= "' . fetch_template('video_fh_bit') . '";');
                        }
                        else
                        {
                       eval('$fhlist .= "' . fetch_template('video_fh_bit_vert') . '";');
                        }
             }
                 eval('$fhlist_shell = "' . fetch_template('video_fh_shell') . '";');
          }


        }
        else
        {
                while ($fh = $db->fetch_array($videos))
                {
                          $fhvideoid = htmlspecialchars_uni($fh['videoid']);
                          fetch_videothumbnail($fh);
                          $fhtitle = $fh['title'];
                          if ($charactertotal == 0)
                          {
                                  $fhdescription = $fh['description'];
                          }
                          else
                          {
                                  $fhdescription = substr($fh['description'],0,$charactertotal);
                          }               
                          $fhviews = $fh['views'];
                          $fhrating = $fh['rating'];
                          $fhcommentcount = $fh['commentcount'];
                   
                         //If there are comments for the video then this query will run.
                         if ($fhcommentcount > 0)
                         {
                                     $comment_query = $db->query("
                                              SELECT * FROM " . TABLE_PREFIX . "videocomment WHERE videoid = " . $fhvideoid . " AND state = 'visible' LIMIT 1");
                                     $comment = $db->fetch_array($comment_query);
                                     $commentuserid = $comment['postuserid'];
                                     $commentusername = $comment['postusername'];
                                     $commentdate = vbdate($vbulletin->options['dateformat'], $comment['dateline'], true);
                         }   

                 eval('$fhlist .= "' . fetch_template('video_forumlist') . '";');
    }
     eval('$fhlist_shell = "' . fetch_template('video_fh_shell_detail') . '";');
   }
  }
}
The title code used in the template files is called $video[title]

I would like the title to be a maximum of 15 characters. I just need to figure out what to add into the plugin code. Thanks in advance for any help!!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:56 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03176 seconds
  • Memory Usage 2,211KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)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_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete