Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Show Full CMS Article in Comments Thread Details »»
Show Full CMS Article in Comments Thread
Version: 1.00, by Lynne Lynne is offline
Developer Last Online: Oct 2022 Show Printable Version Email this Page

Category: Show Thread Enhancements - Version: 4.0.8 Rating:
Released: 11-26-2010 Last Update: Never Installs: 58
Uses Plugins
Re-useable Code  
No support by the author.

This is more of an example than a modification. I wrote this quick plugin for someone and thought I would share it. It's something someone can take and build on. All it does is if you look at the CMS Article thread in your CMS Comments forum, the content of the CMS Article is shown under the blurb "You can view the page at.....". This is ONLY for Articles - not Static Pages or PHP Direct Evaluation content types. Someone can build on this and do those if they want. The person I wrote this for had forms in their articles and needed the submit button to be disabled, so this plugin does that also.

Like I said - this is more of an example. I don't plan to do anything more with it and I'm not helping with modifying it for your own use. Use it however you want.

This adds one query to the threads in the CMS Comments forum.

To install....

Create a Plugin
Hook Location - postbit_display_complete
Title - Show Full CMS Article
Plugin PHP Code -

PHP Code:
if (THIS_SCRIPT == 'showthread' AND $this->thread['forumid'] == $this->registry->options['vbcmsforumid'] AND $this->post['postcount'] == 1) {

$result $this->registry->db->query_first("
    SELECT cms_article.pagetext, cms_article.threadid, cms_article.htmlstate 
    FROM " 
TABLE_PREFIX "cms_article AS cms_article 
    INNER JOIN " 
TABLE_PREFIX "cms_node AS cms_node ON (cms_node.contentid = cms_article.contentid) 
    INNER JOIN " 
TABLE_PREFIX "cms_nodeinfo AS cms_nodeinfo ON (cms_nodeinfo.nodeid = cms_node.nodeid) 
    WHERE cms_nodeinfo.associatedthreadid = "
$this->thread['threadid']. "
        "
);

$bbcode_parser = new vBCms_BBCode_HTML(vB::$vbulletin,  vBCms_BBCode_HTML::fetchCmsTags());

$pagetext fetch_censored_text($bbcode_parser->do_parse($result['pagetext'],true,$result['htmlstate']));

$find 'type="submit"';
$replace 'type="submit" disabled';
$pagetext str_replace ($find$replace$pagetext);

$result['previewtext'] = $pagetext;
$this->post['message'] .= '<br />*********<br />'$result['previewtext'];

CMS Page:

CMS Comment Thread:


If you ONLY want to show the full article to users, not guests, then change this condition (thanks to mattysheff):
PHP Code:
if (THIS_SCRIPT == 'showthread' AND $this->thread['forumid'] ==  $this->registry->options['vbcmsforumid'] AND  $this->post['postcount'] == 1
to this:
PHP Code:
if (THIS_SCRIPT == 'showthread' AND $show['member'] AND  $this->thread['forumid'] == $this->registry->options['vbcmsforumid'] AND $this->post['postcount'] == 1

Download Now

File Type: txt show full cms article.txt (2.0 KB, 137 views)

Screenshots

File Type: png article - cms.png (39.2 KB, 0 views)
File Type: png article - thread.png (63.3 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
3 благодарности(ей) от:
Paul M, tbworld, Toorak Times

Comments
  #72  
Old 07-13-2012, 04:03 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by astdirect View Post
Lynne, great addition and i am using it with no problems. Howeve i just want to ask a related question on whether it is possible to do the same for when you promote a blog ?
I'm not sure I understand what you want. If you promote a blog and then have a comments thread for it, then you can do this same sort of thing for that thread. You do need to modify my original code here if you allow comment threads in several forums though. When I originally wrote it, all comments threads were in one forum.
Reply With Quote
  #73  
Old 07-14-2012, 08:05 AM
astdirect astdirect is offline
 
Join Date: Dec 2009
Posts: 99
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am on 4.1.9

When i promote a thread to a blog the thread continues to take comments but the actual blog page only shows the first post. I would like the blog to also be interacting with the thread and contain the comments...... but it doesn't.
Reply With Quote
  #74  
Old 07-14-2012, 04:06 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by astdirect View Post
I am on 4.1.9

When i promote a thread to a blog the thread continues to take comments but the actual blog page only shows the first post. I would like the blog to also be interacting with the thread and contain the comments...... but it doesn't.
This mod will not help with that at all. You will have to code something to do what you want.
Reply With Quote
  #75  
Old 08-09-2012, 07:53 AM
jesfro jesfro is offline
 
Join Date: Jan 2012
Location: Bremen, Germany
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by brad_irc View Post
Also to be noted, Tapatalk users cannot view articles on main page, now they will be able to view the content using the forum
Hey Brad,
first of all: fantastic work (based on Lynnes)!
It works great in the web browser.
But:
Regarding your Tapatalk statement... this does not work (for us... www.apfeltalk.de). There is no full CMS article in forum via Tapatalk. Anyone else noticed the problem?
Is there something i could set up in the plugin ( hook, order etc.)? Is this a vbulletin or a vbcms?

Thanks a lot in advance ;-)
Reply With Quote
  #76  
Old 09-03-2012, 09:31 PM
TiKu's Avatar
TiKu TiKu is offline
 
Join Date: Sep 2006
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've modified this add-on to display the preview text only. First you need a template called full_cms_in_comments_thread:
Code:
{vb:raw previewtext}<br />
	<span class="cms_article_readmore"><a href="{vb:raw page_url}">{vb:rawphrase read_more_phrase} <img src="{vb:stylevar imgdir_cms}/read_more-{vb:stylevar right}.png" alt="{vb:rawphrase read_more_phrase}" /></a>
	</span>
And this is the new hook code:
Code:
if (THIS_SCRIPT == 'showthread' AND $this->thread['forumid'] == $this->registry->options['vbcmsforumid'] AND $this->post['postcount'] == 1) {
	$result = $this->registry->db->query_first("
	  SELECT cms_article.pagetext, cms_article.threadid, cms_article.htmlstate, cms_node.nodeid, cms_node.userid, cms_node.url
	  FROM " . TABLE_PREFIX . "cms_article AS cms_article
	  INNER JOIN " . TABLE_PREFIX . "cms_node AS cms_node ON (cms_node.contentid = cms_article.contentid)
	  INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS cms_nodeinfo ON (cms_nodeinfo.nodeid = cms_node.nodeid)
	  WHERE cms_nodeinfo.associatedthreadid = ". $this->thread['threadid']. "
	");

	if($result) {
		$contenttypeid = vb_Types::instance()->getContentTypeID('vBCms_Article');
		$allow_html = vBCMS_Permissions::canUseHtml($result['nodeid'], $contenttypeid, $result['userid']);

		$bbcode_parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags());
		$pagetext = $bbcode_parser->get_preview(fetch_censored_text($result['pagetext']), vB::$vbulletin->options['default_cms_previewlength'], $allow_html);
		$result['previewtext'] = strip_bbcode($pagetext);

		$attach = new vB_Attach_Display_Content(vB::$vbulletin, 'vBCms_Article');
		$attachments = $attach->fetch_postattach(0, $result['nodeid']);
		$bbcode_parser->attachments = $attachments;
		$bbcode_parser->unsetattach = true;

		$templater = vB_Template::create('full_cms_in_comments_thread');
		$templater->register('previewtext', fetch_censored_text($bbcode_parser->do_parse($result['previewtext'],true,$result['htmlstate'])));
		$templater->register('page_url', vB_Route::create('vBCms_Route_Content', $result['nodeid'] . ($result['url'] == '' ? '' : '-' . $result['url']))->getCurrentURL());
		$this->post['message'] = $templater->render();
	}
}
Reply With Quote
Благодарность от:
Lynne
  #77  
Old 09-03-2012, 10:25 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for sharing!
Reply With Quote
  #78  
Old 09-04-2012, 03:17 AM
imported_dfmafia's Avatar
imported_dfmafia imported_dfmafia is offline
 
Join Date: Jun 2004
Location: Wherever Uncle Sam Needs!
Posts: 141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm actually trying to get the article/comments forum to post a preview of the thread on vBAdvancec cmps news feed. currently I have been unsuccessful. the comment forums look great with this mod but when I go to cmps it is still displaying "You can view the page at..." instead of the preview
Reply With Quote
  #79  
Old 09-04-2012, 05:28 AM
TiKu's Avatar
TiKu TiKu is offline
 
Join Date: Sep 2006
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Thanks for sharing!
Same to you.
One thing I still don't like, is that if you quote the first post of the comments thread, it quotes only the link to the article. This happens because the mod doesn't actually replace the post text in the database - which I like, because this way you don't have to edit the thread if you edit the article.
Does anyone have an idea how we could make quotations work while keeping the current approach of not replacing the post text in the database?
Reply With Quote
  #80  
Old 09-09-2012, 10:10 AM
TiKu's Avatar
TiKu TiKu is offline
 
Join Date: Sep 2006
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's another improvement:
Add a plugin called "Quote Full CMS Article", hook newreply_quote.
Code:
if (THIS_SCRIPT == 'ajax' AND $quote_post['forumid'] == $vbulletin->options['vbcmsforumid']) {
	$is_first_post = false;
	$result = $vbulletin->db->query_first("SELECT postid FROM " . TABLE_PREFIX . "post WHERE threadid=" . $quote_post['threadid'] . " ORDER BY dateline LIMIT 1");
	if($result) {
		$is_first_post = ($result['postid'] == $quote_post['postid']);
	}

	if($is_first_post) {
		$result = $vbulletin->db->query_first("
		  SELECT cms_article.pagetext, cms_article.threadid, cms_node.nodeid, cms_node.userid
		  FROM " . TABLE_PREFIX . "cms_article AS cms_article
		  INNER JOIN " . TABLE_PREFIX . "cms_node AS cms_node ON (cms_node.contentid = cms_article.contentid)
		  INNER JOIN " . TABLE_PREFIX . "cms_nodeinfo AS cms_nodeinfo ON (cms_nodeinfo.nodeid = cms_node.nodeid)
		  WHERE cms_nodeinfo.associatedthreadid = ". $quote_post['threadid']. "
		");

		if($result) {
			bootstrap_framework();
			$contenttypeid = vb_Types::instance()->getContentTypeID('vBCms_Article');
			$allow_html = vBCMS_Permissions::canUseHtml($result['nodeid'], $contenttypeid, $result['userid']);

			$bbcode_parser = new vBCms_BBCode_HTML($vbulletin, vBCms_BBCode_HTML::fetchCmsTags());
			$pagetext = $bbcode_parser->get_preview(fetch_censored_text($result['pagetext']), $vbulletin->options['default_cms_previewlength'], $allow_html);
		}
	}
}
This makes quotes of the first post of the comments thread quote the article's preview text instead of the link to the article.
Reply With Quote
Благодарность от:
Lynne
  #81  
Old 02-01-2013, 07:24 PM
datoneer datoneer is offline
 
Join Date: Jul 2011
Posts: 453
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Lynne awesome mod!
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 08:21 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.05647 seconds
  • Memory Usage 2,379KB
  • Queries Executed 26 (?)
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
  • (3)bbcode_code
  • (3)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (5)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (3)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete