Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)

Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2004, 03:17 AM
K33nny K33nny is offline
 
Join Date: May 2002
Posts: 184
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default $thread[title]

I would like to put a max character cap on $thread[title] for forumdisplay.php.

Here is my idea but it did not work.

PHP Code:
        $maxthreadtitle 45;
        
$title $ar[$thread[threadid]][title];
        
$maxchars $maxthreadtitle;  
        if (
strlen($title)>$maxchars-1)
         {
         
$spacepos strpos($title." "," ",$maxchars);
        if (
$spacepos!=0)
          {
           
$title substr($title ,0,$spacepos)."...";
          }
         } 
Reply With Quote
  #2  
Old 04-17-2004, 09:15 AM
K33nny K33nny is offline
 
Join Date: May 2002
Posts: 184
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Come on, someone help me! :devious:
Reply With Quote
  #3  
Old 04-17-2004, 07:11 PM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is easier then you think, use:
Code:
$trimmed_title = fetch_trimmed_title($thread['threadid'], 45);
You are done.
Reply With Quote
  #4  
Old 04-17-2004, 07:42 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Isn't that vB3 code you posted, Floren? Will that wrok with vB2?
Reply With Quote
  #5  
Old 04-17-2004, 08:41 PM
K33nny K33nny is offline
 
Join Date: May 2002
Posts: 184
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where would I put your code TECK?
Reply With Quote
  #6  
Old 04-18-2004, 10:07 PM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, Bob is right, this is for VB3.. I didn't realised we are in VB2 section.
Well, look at this function in vb3 functions.php and use the same approach...
Reply With Quote
  #7  
Old 04-18-2004, 11:35 PM
K33nny K33nny is offline
 
Join Date: May 2002
Posts: 184
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

None of this has really helped me in anyway, thanks for trying I guess.
Reply With Quote
  #8  
Old 04-19-2004, 05:13 PM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by K33nny
None of this has really helped me in anyway, thanks for trying I guess.
Well, it's helping you. All you have to do is look at the VB3 function I mentioned and you will be able to make it working.
Let me know if you have any other questions regarding the function.
Reply With Quote
  #9  
Old 04-20-2004, 01:08 AM
K33nny K33nny is offline
 
Join Date: May 2002
Posts: 184
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TECK
Well, it's helping you. All you have to do is look at the VB3 function I mentioned and you will be able to make it working.
Let me know if you have any other questions regarding the function.
I'm not sure what function to look at or the file rather.
Reply With Quote
  #10  
Old 04-20-2004, 06:21 AM
K33nny K33nny is offline
 
Join Date: May 2002
Posts: 184
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
function fetch_trimmed_title($title$chars = -1)
{
    global 
$vboptions;

    if (
$chars == -1)
    {
        
$chars $vboptions['lastthreadchars'];
    }

    if (
$chars)
    {
        
// limit to 10 lines (\n{240}1234567890 does weird things to the thread preview)
        
$titlearr preg_split('#(\r\n|\n|\r)#'$title);
        
$title '';
        
$i 0;
        foreach (
$titlearr AS $key)
        {
            
$title .= "$key\n";
            
$i++;
            if (
$i >= 10)
            {
                break;
            }
        }
        
$title trim($title);
        unset(
$titlearr);

        if (
strlen($title) > $chars)
        {
            
// trim text to specified char length, then trim after last space to avoid half-words
            
return substr($title0strrpos(substr($title0$chars), ' ')) . '...';
        }
        else
        {
            return 
$title;
        }
    }
    else
    {
        return 
$title;
    }

TECK do you realize how confusing that is for me?
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 07:56 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04550 seconds
  • Memory Usage 2,261KB
  • 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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (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_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
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete