Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-01-2008, 10:01 AM
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Speech-mark turns to " in result of a query

I have this function which trims the thread-title of the latest posts after a query fetches the latest posts. Everything works well except I've noticed that if this query trims the thread-title at a speech-mark ( " ) , instead of displaying the speech-mark in the result it shows &quo... instead. But if I increase the cut-off by a few more characters then the speech mark is displayed correctly. How can I make the query display the speech-mark without it displaying '&quot...' at certain lengths of cutoff?

Here is the query to trim the thread-title:

PHP Code:
if (strlen($row['thread_title']) > $vbulletin->options['latest_trimplusthree'])
       {
        
// adds the cutoff ... with substr
        
$row['thread_title'] = substr($row['thread_title'], 0$vbulletin->options['latest_trim']) . '...';
       } 
--------------- Added [DATE]1220329262[/DATE] at [TIME]1220329262[/TIME] ---------------

someone help please...
Reply With Quote
  #2  
Old 09-03-2008, 12:27 AM
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

has this been posted in the right section?
Reply With Quote
  #3  
Old 09-03-2008, 09:40 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try using multibyte functions instead. So mb_substr() instead of substr(), and mb_strlen() instead of strlen().
Reply With Quote
  #4  
Old 09-03-2008, 10:17 AM
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your reply, I've just tried that but it still shows &quo... in the results.

--------------- Added [DATE]1220440916[/DATE] at [TIME]1220440916[/TIME] ---------------

This is the query which fetches the latest posts:

PHP Code:
// query to get the last posts
    
$query $vbulletin->db->query_read_slave("
        SELECT
            post.postid, post.pagetext as pagetext, post.userid, post.username, post.dateline AS date,
            thread.forumid, thread.title as thread_title, thread.threadid,
            forum.forumid, forum.title as forum_title, thread.replycount as replies, thread.views as views
        FROM " 
TABLE_PREFIX "thread AS thread
        INNER JOIN " 
TABLE_PREFIX "post AS post on (post.postid = thread.lastpostid)
        INNER JOIN " 
TABLE_PREFIX "forum AS forum on (thread.forumid = forum.forumid)
        WHERE post.visible = '1' AND thread.visible = '1' AND open = '1' AND 
$platest_and AND $platest_and_1
        ORDER BY postid DESC
        LIMIT 
$plimit"
    
); 
Reply With Quote
  #5  
Old 09-03-2008, 10:50 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try the fetch_trimmed_title vBulletin function instead.
Reply With Quote
  #6  
Old 09-03-2008, 01:03 PM
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
Try the fetch_trimmed_title vBulletin function instead.
Thanks but I have no idea how to use that function.
Reply With Quote
  #7  
Old 09-03-2008, 01:27 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you click the link and read the function description?
Reply With Quote
  #8  
Old 09-03-2008, 04:56 PM
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
Did you click the link and read the function description?
How can I make that function work with this query:

PHP Code:
// query to get the last posts
    
$query $vbulletin->db->query_read_slave("
        SELECT
            post.postid, post.pagetext as pagetext, post.userid, post.username, post.dateline AS date,
            thread.forumid, thread.title as thread_title, thread.threadid,
            forum.forumid, forum.title as forum_title, thread.replycount as replies, thread.views as views
        FROM " 
TABLE_PREFIX "thread AS thread
        INNER JOIN " 
TABLE_PREFIX "post AS post on (post.postid = thread.lastpostid)
        INNER JOIN " 
TABLE_PREFIX "forum AS forum on (thread.forumid = forum.forumid)
        WHERE post.visible = '1' AND thread.visible = '1' AND open = '1' AND 
$platest_and AND $platest_and_1
        ORDER BY postid DESC
        LIMIT 
$plimit"
    
); 
Reply With Quote
  #9  
Old 09-03-2008, 06:27 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't use it in the query... you do it to the title you've fetched.
Reply With Quote
  #10  
Old 09-03-2008, 06:57 PM
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The query has the following line which fetches the thread title, doesn't it?

PHP Code:
 SELECT
          thread
.title as thread_title 

I have to use that query to get the latest posts on the forum, but the part I'm stuck on is using a function to correctly trim the thread-title of these latest posts.

If I use the function you linked to, I would have to make it work with this query which fetches the actual posts, is that not correct? The title itself isn't enough because I need the thread-titles to link to the latest posts.
Reply With Quote
Reply


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 11:35 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.04082 seconds
  • Memory Usage 2,265KB
  • Queries Executed 13 (?)
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
  • (4)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