Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
[previewbreak] for blog posts Details »»
[previewbreak] for blog posts
Version: 1.00, by xorlof xorlof is offline
Developer Last Online: Aug 2020 Show Printable Version Email this Page

Category: BB Code Enhancements - Version: 4.2.2 Rating:
Released: 02-03-2015 Last Update: Never Installs: 5
Re-useable Code Code Changes  
No support by the author.

This is my first attempt at making something for VB4, so be kind. Tips/tricks on how I could have done this better are most welcome...

The CMS has the code [prbreak] which allows you to specify exactly where you want the shortened version of an article to stop, after which you can hit the "read more" link to see the rest. The blog system doesn't have this functionality, so I hacked it in. There are two steps needed to make this work:

STEP ONE: CREATE A [PREVIEWBREAK] BB CODE
a) Goto Admin CP -> Custom BB Code -> BB Code Manager -> Add New BB Code
b) Fill out the form as follows:
Title: Preview Break (blog only)
Tag name: previewbreak
Replacement: <!-- preview break -->
Example: [previewbreak][/previewbreak]
Description: Include an empty [previewbreak] tag ( [previewbreak][/previewbreak] ) to force a blog preview to end at that point instead of after a certain number of characters (the default behavior).
STEP TWO: EDIT THE BLOG BBCODE PARSER
Sorry--I couldn't figure out a way to do this without editing source code. Anyway, we have to edit class_bbcode_blog.php (from the vBulletin "includes" directory) in three places:

Edit #1: Find:
PHP Code:
                if ($this->parse_userinfo['permissions']['vbblog_entry_permissions'] & $this->registry->bf_ugp_vbblog_entry_permissions['blog_allowhtml'])
                {
                        
$input_text strip_tags($input_text'<br>');
                } 
and on new lines after the closing curly brace add this:
PHP Code:
                // NON-STANDARD CODE - If present, we will break at [previewbreak] instead of after a certain number of characters
                
if (stripos($input_text''))
                {
                        
$this->snippet_length strlen($input_text);
                }
                
// END OF NON-STANDARD CODE 
Edit #2: Repeat edit #1 in the other spot the find text occurs in the same file.

Edit #3: Find:
PHP Code:
                                if ($token['type'] == 'tag')
                                { 
and on new lines after that opening curly brace add this:
PHP Code:
                                        // NON-STANDARD CODE - If we have a prbreak we are done.
                                        
if (($token['name'] == 'previewbreak') AND isset($tokens[intval($tokenid) + 1])
                                                AND (
$tokens[intval($tokenid) + 1]['name'] == 'previewbreak')
                                                AND (
$tokens[intval($tokenid) + 1]['closing']))
                                        {
                                                
$over_threshold == true;
                                                break;
                                        }
                                        
// END OF NON-STANDARD CODE 
That's it! Now you can insert [previewbreak][/previewbreak] anywhere within your blog post to force the break at that spot. It even works if the forced spot occurs after the regular (non-forced) break would occur (i.e., you can lengthen a preview using this code).

And with a little bit of reworking, it would be pretty straightforward to allow you to put text between the opening and closing previewbreak tags that is only shown on the preview page (e.g., "[previewbreak]Read on to find out why [subject of blog post] is so great.[/previewbreak]"). Since I doubt this will be a popular mod (I'll consider 2 installs, including me to be a huge success), and I have no use for that, I'll leave that to someone else.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 02-04-2015, 05:00 PM
xorlof xorlof is offline
 
Join Date: Sep 2012
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reserved.

(Not that I think I'll need this spot, but it's what all the cool kids around here do!)
Reply With Quote
  #3  
Old 02-07-2015, 07:33 AM
xorlof xorlof is offline
 
Join Date: Sep 2012
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Woo Hoo! My first (not me) install! I don't know who you are, but let me know if you have questions/problems. (While I have this marked as unsupported, I'm happy to answer questions/troubleshoot as I can. I just don't want to promise support).
Reply With Quote
Reply

Thread Tools

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:47 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.05476 seconds
  • Memory Usage 2,236KB
  • Queries Executed 17 (?)
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
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (2)postbit
  • (3)postbit_onlinestatus
  • (3)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete