View Single Post
  #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
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01127 seconds
  • Memory Usage 1,799KB
  • Queries Executed 11 (?)
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
  • (1)bbcode_code
  • (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_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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete