Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons

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
  #82  
Old 06-02-2013, 07:05 PM
Morrus Morrus is offline
 
Join Date: Jan 2002
Posts: 494
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is great - been using it for a while. One issue is that inline image attachments do not show in the thread - you just get a URL link instead.

[Edit - ah, I see this has been mentioned plenty of times!]
Reply With Quote
  #83  
Old 06-05-2013, 02:45 PM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I love this but am having a major issue.

I want to have certain article previews appear in other forums instead of the main forum but when I more the threads they automatically go back to default. Is there any way to get the previews to show in other forums as well?

After looking at the code I see I may be able add an array and list the forums but will this add a query for each forum I add for every page load or just when someone opens that forum? Will this change the forums the articles are posted in?
Reply With Quote
  #84  
Old 06-05-2013, 02:49 PM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
That is because of the condition I have at the top:
Code:
if (THIS_SCRIPT == 'showthread' AND $this->thread['forumid'] == $this->registry->options['vbcmsforumid'] AND $this->post['postcount'] == 1)
I have it set to only check for this in the specified vbcms comments forum. You could remove that part of the condition and see if it works. (Do you always move the threads to a specific other forum? If so, enter that forumid instead.)
Sorry I missed this--will try this.

Thanks guys


This has worked but I want to do a couple more things. if anyone has already done this please share.

#1 - I want to only show a preview and not the entire article..

#2 - I want to make the preview content not crawlable. I do not want it indexed from both the article page and the forum.(I don't think this is an issue because the content is being generated from the cms and not actually posted as a regular thread so disregard number 2--

#3 - Being able to add the images would also be cool..

Thanks--Love this!
Reply With Quote
  #85  
Old 06-05-2013, 05:50 PM
Toorak Times's Avatar
Toorak Times Toorak Times is offline
 
Join Date: Jan 2011
Posts: 436
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Glad I found this. Applied it tonight, Lynne's and the latest version, cheers!

It works very well with text on my 4.2.1 site, first few I looked at the pics didn't come through, and I don't expect the vBTubes to come thru but when I looked deeper pics were being feed into the thread.

It has fixed up hundreds of posts that NOW I can call an archive, wonderful, I'll definitely keep an eye on this thread hoping for further shared enhancements.

I was starting to build an archive in the CMS as the links didn't allow me to delete some of the dated. I presume I can delete the dated content from the CMS now as we have copy in this plugin.

Thanks again.
Reply With Quote
  #86  
Old 06-05-2013, 09:57 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 Toorak Times View Post
I was starting to build an archive in the CMS as the links didn't allow me to delete some of the dated. I presume I can delete the dated content from the CMS now as we have copy in this plugin.

Thanks again.
No, you cannot delete the CMS article. If you do that, then there will be no text in the post. This modification does not actually copy it from the CMS part of the database into the post, it just shows the CMS content in place of the existing post.
Reply With Quote
  #87  
Old 06-06-2013, 08:37 AM
Toorak Times's Avatar
Toorak Times Toorak Times is offline
 
Join Date: Jan 2011
Posts: 436
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
No, you cannot delete the CMS article. If you do that, then there will be no text in the post. This modification does not actually copy it from the CMS part of the database into the post, it just shows the CMS content in place of the existing post.
Thanks Lynne, I learnt today when I tried to edit one of them to replace the pictures the content also disappears.
Reply With Quote
  #88  
Old 06-07-2013, 02:21 PM
Morrus Morrus is offline
 
Join Date: Jan 2002
Posts: 494
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So I've done something silly, and I think it may have messed up something.

I had changed the phrase which says "You can view the page at X" a while back to something else. Yesterday, I went to change it again, and deleted the translation and saved it. Now I can't find the phrase! I usually find phrases by just searching for them, but I can't search for " ".

How do I find that phrase again? Does it have a Phrase Variable Name I can search for instead of the text?

--

Additionally, at the exact same time (it might be coincidence, but it might be linked to the above) the CMS has stopped putting the comment thread in the CMS comments forum altogether, and despite comments being set to YES in the article edit page, comments appear to be remaining switched off. I don't know if that's somehow connected to me accidentally removing a phrase (it seems unlikely, but the timing was pretty much exact).
Reply With Quote
  #89  
Old 06-07-2013, 04:32 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 Morrus View Post
So I've done something silly, and I think it may have messed up something.

I had changed the phrase which says "You can view the page at X" a while back to something else. Yesterday, I went to change it again, and deleted the translation and saved it. Now I can't find the phrase! I usually find phrases by just searching for them, but I can't search for " ".

How do I find that phrase again? Does it have a Phrase Variable Name I can search for instead of the text?
The phrase name is "comment_thread_firstpost".

Quote:
Originally Posted by Morrus View Post
Additionally, at the exact same time (it might be coincidence, but it might be linked to the above) the CMS has stopped putting the comment thread in the CMS comments forum altogether, and despite comments being set to YES in the article edit page, comments appear to be remaining switched off. I don't know if that's somehow connected to me accidentally removing a phrase (it seems unlikely, but the timing was pretty much exact).
I can't see how the two are related.
Reply With Quote
  #90  
Old 06-07-2013, 04:38 PM
Morrus Morrus is offline
 
Join Date: Jan 2002
Posts: 494
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
The phrase name is "comment_thread_firstpost".
Got it - thanks!


Quote:
I can't see how the two are related.
They definitely are in some way, because reverting that phrase immediately turned comments back on again! Everything is working correctly again!

I just tested it and removed and then re-added the phrase again. Removing it immediately switches off CMS comments threads (and therefore comments); adding it back restores the functionality.
Reply With Quote
  #91  
Old 06-09-2013, 05:12 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TiKu View Post
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.
Just what I needed!! Thanks!

Any clue how to get the image to display?
Reply With Quote
Благодарность от:
Toorak Times
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 06:39 PM.


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.04523 seconds
  • Memory Usage 2,374KB
  • 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
  • (2)bbcode_code
  • (3)bbcode_php
  • (8)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
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (4)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)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