vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Show Thread Enhancements - Show Full CMS Article in Comments Thread (https://vborg.vbsupport.ru/showthread.php?t=254333)

Lynne 11-26-2010 10:00 PM

Show Full CMS Article in Comments Thread
 
1 Attachment(s)
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:
https://vborg.vbsupport.ru/attachmen...1&d=1290890523
CMS Comment Thread:
https://vborg.vbsupport.ru/attachmen...1&d=1290890523

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


Dr.osamA 12-13-2010 10:09 PM

installed

but i have broplem with cms as default

Lynne 12-13-2010 10:30 PM

Quote:

Originally Posted by Dr.osamA (Post 2133503)
installed

but i have broplem with cms as default

Sorry, but I don't understand what you mean.

jimfries 12-30-2010 01:39 AM

After I put in this plug-in, activate it then reload my website I get this Error:
==================
Database error in vBulletin 4.0.1:

Invalid SQL:

SELECT cms_article.pagetext, cms_article.threadid, cms_article.htmlstate
FROM distortedforumscms_article AS cms_article
INNER JOIN distortedforumscms_node AS cms_node ON (cms_node.contentid = cms_article.contentid)
INNER JOIN distortedforumscms_nodeinfo AS cms_nodeinfo ON (cms_nodeinfo.nodeid = cms_node.nodeid)
WHERE cms_nodeinfo.associatedthreadid = 570;

MySQL Error : Unknown column 'cms_article.htmlstate' in 'field list'
Error Number : 1054
Request Date : Wednesday, December 29th 2010 @ 08:37:48 PM
Error Date : Wednesday, December 29th 2010 @ 08:37:48 PM
Script : http://www.distortedguild.com/showth...ate-12-30-2010
Referrer : http://www.distortedguild.com/forumd...p?5-Guild-Chat
IP Address : 76.125.212.129
Username : Guadah
Classname : vB_Database
MySQL Version : 4.1.24-max-log


Here is the code I put into the Plug-in. I just copied and pasted it.
==================
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'];
}

Lynne 12-30-2010 03:13 AM

Quote:

Originally Posted by jimfries (Post 2141110)
After I put in this plug-in, activate it then reload my website I get this Error:
==================
Database error in vBulletin 4.0.1:

Invalid SQL:

.....

MySQL Error : Unknown column 'cms_article.htmlstate' in 'field list'

I just wrote this recently, so I've only been able to test it on 4.0.8 and up. There may not have been a field called htmlstate in the cms_article table back in 4.0.1. If so, then I'm not sure if this will work for you without modifying the query and the do_parse call.

jimfries 12-30-2010 03:35 AM

oh man, what a bummer.

I'm not sure I can upgrade, I think one or two addons will stop working if I do. I'll backup the website and try to upgrade this weekend when I have time.

Thanks for the work done in it regardless! It's an awesome modification.

jimfries 12-30-2010 04:55 AM

I removed ", cms_article.htmlstate" and submitted it. The addon is working now :)

Thank you again for this modification!

GamerPerfection 12-30-2010 11:05 AM

Tagged.... will try later today.... hope it works on 4.1.0 :)

GamerPerfection 12-30-2010 04:28 PM

It works. :)

One problem I have though, which is not an issue with it as it is, but more with how I personally do things on my forum. Once I publish an article, I then go to the forum and I move the thread from vBCMS Comments to a more relevant section of the forum. When I move it the article content in the thread disappears and i'm left with the standard "you can view the page here".

The way around it I have at the moment is I copy the content from the auto created thread, then I move the thread, then edit the thread and paste in the content. It works, but it means a little more work on my behalf. :)

Lynne 12-30-2010 04:58 PM

Quote:

Originally Posted by GamerPerfection (Post 2141394)
It works. :)

One problem I have though, which is not an issue with it as it is, but more with how I personally do things on my forum. Once I publish an article, I then go to the forum and I move the thread from vBCMS Comments to a more relevant section of the forum. When I move it the article content in the thread disappears and i'm left with the standard "you can view the page here".

The way around it I have at the moment is I copy the content from the auto created thread, then I move the thread, then edit the thread and paste in the content. It works, but it means a little more work on my behalf. :)

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.)

GamerPerfection 12-30-2010 08:39 PM

Awesome, removing the bit in red works! When I move it to anywhere in the forum it still keeps the content.

And no I don't move them to the same specific area, it can vary.

But thanks for helping me fix it. :)

mattysheff 01-15-2011 03:32 PM

Thanks for releasing this Lynne, its just what I've been looking for.

One question though, is it possible and if so how would I to it to only get it to show the text to signed in members. I've been trying to figure out how to do it myself but getting nowhere, as while its a user friendly feature, I don't want search engines to be able to see it as I don't want duplicated content listed in the search engines.

Lynne 01-15-2011 04:01 PM

Just add a condition to the plugin to only do it if the user is logged in - you can probably use the $show['member'] variable for that.

mattysheff 01-22-2011 05:03 PM

Thanks that works perfect.

tokenyank 01-22-2011 10:37 PM

This looks like a great mod - however, wouldn't this count against your SEO by having duplicate content?

Tagged for further investigation when it isn't 00:40! ;)

Lynne 01-22-2011 11:06 PM

Quote:

Originally Posted by tokenyank (Post 2153132)
This looks like a great mod - however, wouldn't this count against your SEO by having duplicate content?

Tagged for further investigation when it isn't 00:40! ;)

According to mattysheff, yes, which is why he asked the question and I told him to put the condition around it.

mattysheff 01-23-2011 07:04 AM

I've added this to the first bit:

if (THIS_SCRIPT == 'showthread' AND $show['member'] AND $this->thread['forumid'] == $this->registry->options['vbcmsforumid'] AND $this->post['postcount'] == 1)

It works perfect and only shows the content to members. I'm not currently using it though because I've got comment threads hidden because of the bug in vbulletin where if you future publish a article the comment thread is created immediately.

deverill2010 03-13-2011 03:37 PM

Hi Lynne and thanks for the mod but what exactly do you mean by -

Quote:

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.
The ability to reply is removed??

Lynne 03-13-2011 04:28 PM

Quote:

Originally Posted by deverill2010 (Post 2172889)
Hi Lynne and thanks for the mod but what exactly do you mean by -

The ability to reply is removed??

No. This mod only effect the post text, nothing else.

traen 03-14-2011 02:37 AM

Installed, works great thank you Lynne! This should be default in vbulletin.

whitedd 03-19-2011 04:32 PM

Thnx Lynn ...but i wonder...is it posible that shows a attacment too...
...couse...article is showing,but in every article i have one image...
...thats images is not showing...only text and link to attachments...:(

can check here : http://www.braniteljski-forum.info/f...d.php?p=208345

Lynne 03-19-2011 04:37 PM

Quote:

Originally Posted by whitedd (Post 2175148)
Thnx Lynn ...but i wonder...is it posible that shows a attacment too...
...couse...article is showing,but in every article i have one image...
...thats images is not showing...only text and link to attachments...:(

can check here : http://www.braniteljski-forum.info/f...d.php?p=208345

You are welcome to modify the plugin however you want. As I said at the beginning, it's more of an example of how to do this and you may modify it to suite your own needs.

deverill2010 03-20-2011 06:51 PM

Whitedd if you do edit it to allow attachments, can you please share as I also need to show attachments.

Thanks!

whitedd 03-21-2011 12:25 PM

...i try..but...hmmm...iam not a Coder...
...if anybody know how to do that,share with us...
...i realy need this... :(

YkudzA 03-21-2011 12:29 PM

Quote:

Originally Posted by deverill2010 (Post 2175538)
Whitedd if you do edit it to allow attachments, can you please share as I also need to show attachments.

Thanks!

Yes, it will be very useful !

deverill2010 03-22-2011 12:55 PM

Lynne pretty please? If I could code I'd do it and share but I'm not a coder and have no hope of learning how to code.

Please :D

Lynne 03-22-2011 03:23 PM

Sorry, I never even needed this mod in the first place but wrote it for someone who did. I posted at the beginning that it's more of an example of what can be done and how to do it.

apaydin2148 05-18-2011 02:42 PM

Is it working with 4.1.3?

Lynne 05-18-2011 03:16 PM

Quote:

Originally Posted by apaydin2148 (Post 2197199)
Is it working with 4.1.3?

Works fine on my 4.1.3 test site.

deverill2010 05-18-2011 04:28 PM

Same here works perfectly fine on my live site :)

Alp Ozdemir 08-11-2011 02:42 PM

youtube links rendered in the messages but images is not, how can I show the images?

Lynne 08-11-2011 03:05 PM

Quote:

Originally Posted by Alp Ozdemir (Post 2232254)
youtube links rendered in the messages but images is not, how can I show the images?

You would need to modify the code to actually get the images to show. As I said at the top of the thread - this is more of an example of how you can do this. So, modify the code however you need it for your needs.

GamersChallenge 08-21-2011 07:18 PM

lol at everyone asking for the attachments, I guess I'll join the team.

please please please :(

deverill2010 08-22-2011 05:49 PM

Lynne as you've put reusable code, I have made a request for someone to modify it to show images - https://vborg.vbsupport.ru/showthrea...59#post2236659

I hope you don't mind as I really need this.

Lynne 08-23-2011 12:55 AM

Quote:

Originally Posted by deverill2010 (Post 2236660)
Lynne as you've put reusable code, I have made a request for someone to modify it to show images - https://vborg.vbsupport.ru/showthrea...59#post2236659

I hope you don't mind as I really need this.

I don't mind at all. It is reusable for that reason. I only got so far with it in order to help someone else out with a specific request and just posted this in case if would help someone else get started to do something similar, or even more. :)

brad_irc 09-11-2011 07:34 PM

Quote:

Originally Posted by Lynne (Post 2236829)
I don't mind at all. It is reusable for that reason. I only got so far with it in order to help someone else out with a specific request and just posted this in case if would help someone else get started to do something similar, or even more. :)

Thanks for your snippet Lynne. I do many vB mods that are never published, but your code snippet helped -- so here is the solution for users wanting [ATTACH] bbcode parsed properly. :D

Let me explain so users can better understand the code and why it appears as a link.

Deep inside /includes/class_bbcode.php, line 2581 "if (!empty($this->attachments["$attachmentid"]))" checks if the $bbcode_parser object has an array defined with details about the image attachment (ie; size, contenttype, placement, thumbnail, etc). If that data is not present, it defaults to creating a link to the attachment.

I backtracked through the function where CMS article calls the bbcode parser, see file /packages/vbcms/item/content/article.php, line 428 which shows how it fetches the attachment data using the content nodeid.

The snippet below has nodeid added to the query, and the block populating the $attachments array. Enjoy :)

Also to be noted, Tapatalk users cannot view articles on main page, now they will be able to view the content using the forum

PHP Code:

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

$result $this->registry->db->query_first("
       SELECT cms_article.pagetext, cms_article.threadid, cms_article.htmlstate, cms_node.nodeid  
    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) {
        
$bbcode_parser = new vBCms_BBCode_HTML(vB::$vbulletinvBCms_BBCode_HTML::fetchCmsTags());;
        
        
$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;
        
        
$this->post['message'] = fetch_censored_text($bbcode_parser->do_parse($result['pagetext'], true$result['htmlstate']));
            
    }  


PS: If anyone else has noticed that [ATTACH] is not properly parsed in RSS feeds, I will find a solution and post it in the next couple days.

Lynne 09-12-2011 12:30 AM

Thank you, Brad!

GamersChallenge 09-12-2011 12:42 AM

thanx brad, works great

deverill2010 09-14-2011 04:14 PM

Brad much appreciated!!!!! xxx

BearOlympic 01-24-2012 05:34 PM

Quote:

Originally Posted by Lynne (Post 2141413)
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.)

Thanks a lot for this mod!
Just one thing - if you remove this condition - you will get text "*********" displayed in every first message of every topic. Because almost every topic meets other conditions.

As for me - i don't mind it, and i don't need a divider between auto-created text and article. so i just replaced that code with " ". not good - but fast )


All times are GMT. The time now is 02:22 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.01420 seconds
  • Memory Usage 1,876KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (4)bbcode_php_printable
  • (13)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete