PDA

View Full Version : vBulletin Blog - Limit RSS Feed Text


Aaron310012
04-15-2012, 01:26 AM
Hello,

I am searching for a way to limit the amount of text for the Blog RSS feed. Right now the feed is displaying the entire contents of each and all blog posts and I would like to find a way to limit this to a preview. I found the thread below and still have been unable to get this working on the Blog portion of the site:

https://vborg.vbsupport.ru/showthread.php?t=166703

This uses a plugin with an external_query hook location.

Code:

unset($vbulletin->GPC['fulldesc']);
$vbulletin->options['threadpreview'] = 250;
$hook_query_fields .= ",LEFT(post.pagetext,400) AS message";

I have created this plugin for the vBulletin, vBulletin Blog, and vBulletin CMS products and have enabled all three.

However, while this seems to have worked for the Forum & CMS, the Blog feed still displays the entire contents of every Blog post. Interestingly, I've found that even if I enable only the CMS plugin, it will shorten the feed for the CMS and Forum, but I can't find a way to limit the RSS feed text for the Blog.

Does anyone know of a way or modification to this plugin that might work?

Any advice or thoughts on the issue would really be appreciated!

Aaron310012
04-20-2012, 01:19 AM
Just wondering if anyone might have any thoughts? Thanks!

Aaron310012
04-24-2012, 10:25 PM
I just found that there is also a specific blog_external_query template hook and tried that, but am receiving a database error when trying to subscribe to the RSS feed while the plugin is enabled.

Aaron310012
04-27-2012, 01:25 AM
By chance, does anyone have any idea why I might get this database error with this template hook? I'm thinking that finding the solution to the error might point me down the path towards resolution.

Or perhaps there is a better approach to limit the RSS feed of the blog?

Again thanks for any input on this one!

Lynne
04-27-2012, 01:26 AM
What is the exact hook and code you are using and the exact database error?

Aaron310012
04-27-2012, 02:23 AM
Lynne,

Thank you for your response. Just to recap, I have enabled RSS in the VB options. I then found this thread about limiting the RSS feed:

https://vborg.vbsupport.ru/showthread.php?t=166703

So at this point, I am using the plugin code:

unset($vbulletin->GPC['fulldesc']);
$vbulletin->options['threadpreview'] = 250;
$hook_query_fields .= ",LEFT(post.pagetext,400) AS message";

And I have created 3 separate plugins; 1 for the CMS product, 1 for the Forum product, and 1 for the Blog product.

This has worked great for the CMS and Forum, those RSS feeds are limited. However, I have tried both the external_query and the blog_external_query hooks using the code above but the blog RSS feed is not limited. Additionally, when using the blog_external_query hook only, I receive the database error when clicking the RSS icon from within the blog. Here is the database error:

Database error in vBulletin 4.1.12:

Invalid SQL:

SELECT blog.*, blog_text.*, user.*
,LEFT(post.pagetext,400) AS message
FROM blog AS blog
INNER JOIN blog_text AS blog_text ON (blog.firstblogtextid = blog_text.blogtextid)
INNER JOIN blog_user AS blog_user ON (blog_user.bloguserid = blog.userid)
LEFT JOIN user AS user ON (user.userid = blog_text.userid)


WHERE 1=1
AND blog.state = 'visible'
AND blog.dateline <= 1335495900
AND blog.pending = 0
AND blog_user.options_guest & 1
AND ~blog.options & 8



ORDER BY blog.dateline DESC
LIMIT 15;

MySQL Error : Unknown column 'post.pagetext' in 'field list'
Error Number : 1054
Request Date : Thursday, April 26th 2012 @ 09:05:00 PM
Error Date : Thursday, April 26th 2012 @ 09:05:00 PM
Script : http://www.mysite.com/blog_external.php?type=RSS2
Referrer : http://www.mysite.com/blog.php
IP Address : ***.**.***.***
Username : Unregistered
Classname : vB_Database
MySQL Version :

Any thoughts would be highly appreciated, I would really like to enable RSS for the blog, however I would prefer that the RSS feed only be a preview to the full content which could be found directly on my site if at all possible.

kh99
04-27-2012, 04:25 AM
Try this plugin code:

unset($vbulletin->GPC['fulldesc']);
$vbulletin->options['threadpreview'] = 250;
$hook_query_fields .= ",LEFT(blog_text.pagetext,400) AS pagetext";

Lynne
04-27-2012, 04:26 PM
^^ what he said. There is no post table being called in the query, so you can't do what you did.

Aaron310012
04-28-2012, 01:01 AM
Kevin & Lynne - That worked, thanks! Very highly appreciated! Now if I can only figure out how to add a "..." or something similar after the truncated text I'll be all set, but this has been extremely helpful and obviously solved the main concern!