Version: 1.6, by OcR Envy
Developer Last Online: Nov 2023
Category: vBulletin CMS Widgets -
Version: 4.0.0
Rating:
Released: 01-06-2010
Last Update: Never
Installs: 65
Auto-Templates
Re-useable Code Translations
No support by the author.
Latest Articles In Section
What is does:
vBCMS only has one option for latest articles and that is all sections and categories. This widget will allow you to display the latest articles in a specific section.
Change Log: 1.0 - Initial Release
1.1 - Updated to allow more than one section & display published date.
1.2 - Small update, no need to update unless you are using a table prefix.
1.3 - Added full page text if no previewtext row exists.
1.4 - Updated to not show unpublished articles.
1.5 - Updated read more link to look more vBulletin related.
1.6 - Small change to fix 4.0.2 [ATTACH] showing in text.
Installation:
Goto AdminCP-vBullietin CMS-Widgets->Create New Widget
Choose PHP Direct Execution as Widget's Type
Enter A Title IE: "Latest (Insert Your Section Name Here)"
Click Save
Click Configure
Remove all the default code.
Copy and Paste the code below first editing $section and $limit to your liking
Click Save
Goto AdminCP-vBullietin CMS-Layout Manager
Add the Widget to your Layout
Click Save
How do I find my section id? When clicking on your section you should see something like this:
The number after ? in this case 11 is your section id.
Can I enter more than one section id? Yes simply change $section = '11' to something like $section='11, 12, 13'
Code to copy(make sure you change $section and $limit!)
PHP Code:
// Set Your Section ID Here $section = '11'; // Set The Number of Articles To Display $limit = '1'; // Set The Height of The Thumbnail Image $height = '250'; // Set The Width of The Thumbnail Image $width = '250';
$articlegrab = vB::$db->query_read(" SELECT ".TABLE_PREFIX."cms_nodeinfo.nodeid , ".TABLE_PREFIX."cms_nodeinfo.title , ".TABLE_PREFIX."cms_article.previewimage , ".TABLE_PREFIX."cms_article.previewtext , ".TABLE_PREFIX."cms_article.pagetext , ".TABLE_PREFIX."cms_article.contentid , ".TABLE_PREFIX."cms_node.nodeid , ".TABLE_PREFIX."cms_node.parentnode , ".TABLE_PREFIX."cms_node.contentid , ".TABLE_PREFIX."cms_node.url , ".TABLE_PREFIX."cms_node.publishdate , ".TABLE_PREFIX."cms_node.setpublish FROM ".TABLE_PREFIX."cms_article , ".TABLE_PREFIX."cms_nodeinfo , ".TABLE_PREFIX."cms_node WHERE (".TABLE_PREFIX."cms_nodeinfo.nodeid = ".TABLE_PREFIX."cms_node.nodeid) AND (".TABLE_PREFIX."cms_article.contentid = ".TABLE_PREFIX."cms_node.contentid) AND (".TABLE_PREFIX."cms_node.parentnode IN ($section)) AND (".TABLE_PREFIX."cms_node.setpublish != 0) ORDER BY ".TABLE_PREFIX."cms_node.publishdate DESC LIMIT $limit ");
Sorry, I don′t get the idea as to connect this code:
Quote:
Originally Posted by XManuX
Note that you can "easily" modify it to have the "best rated articles of this month"
1?) Add this in the SELECTed fields :
Code:
, ".TABLE_PREFIX."cms_nodeinfo.ratingtotal
2?) Add this condition in your request to limit results to the current month (and year) :
Code:
AND (MONTH(FROM_UNIXTIME(".TABLE_PREFIX."cms_node.publishdate))=MONTH(NOW()) AND YEAR(FROM_UNIXTIME(".TABLE_PREFIX."cms_node.publishdate))=YEAR(NOW()))
3?) Replace the ORDER part :
Code:
ORDER BY ".TABLE_PREFIX."cms_node.publishdate DESC LIMIT $limit
with:
Code:
ORDER BY ".TABLE_PREFIX."cms_nodeinfo.ratingtotal DESC LIMIT $limit
4?) In the While (where all variables are initialized) :
Code:
$rating = $articleinfo['ratingtotal'];
5?) Add somewhere in the $output string definition:
Code:
<span class=\"cmsrating rating{$rating}\"></span>
Regards.
With this code, please for the help.
PHP Code:
// Set Your Section ID Here $section = '11'; // Set The Number of Articles To Display $limit = '1'; // Set The Height of The Thumbnail Image $height = '250'; // Set The Width of The Thumbnail Image $width = '250';
$articlegrab = vB::$db->query_read(" SELECT ".TABLE_PREFIX."cms_nodeinfo.nodeid , ".TABLE_PREFIX."cms_nodeinfo.title , ".TABLE_PREFIX."cms_article.previewimage , ".TABLE_PREFIX."cms_article.previewtext , ".TABLE_PREFIX."cms_article.pagetext , ".TABLE_PREFIX."cms_article.contentid , ".TABLE_PREFIX."cms_node.nodeid , ".TABLE_PREFIX."cms_node.parentnode , ".TABLE_PREFIX."cms_node.contentid , ".TABLE_PREFIX."cms_node.url , ".TABLE_PREFIX."cms_node.publishdate , ".TABLE_PREFIX."cms_node.setpublish FROM ".TABLE_PREFIX."cms_article , ".TABLE_PREFIX."cms_nodeinfo , ".TABLE_PREFIX."cms_node WHERE (".TABLE_PREFIX."cms_nodeinfo.nodeid = ".TABLE_PREFIX."cms_node.nodeid) AND (".TABLE_PREFIX."cms_article.contentid = ".TABLE_PREFIX."cms_node.contentid) AND (".TABLE_PREFIX."cms_node.parentnode IN ($section)) AND (".TABLE_PREFIX."cms_node.setpublish != 0) ORDER BY ".TABLE_PREFIX."cms_node.publishdate DESC LIMIT $limit ");
It still works on 4.2 I have changed my code of how it looks. Maybe I'll post it. It helped me alot with longer titles. I just haven't figured out how to get the preview text to show on 4.2.
I was having issues with vbseo, than I just did this.
PHP Code:
<a href='content.php?".$nodeid."-".$url."'>
and changed it to this.
PHP Code:
<a href='/content.php?r=".$nodeid."-".$url."'>
Clicking the links seemed to work. Also I am getting my preview text to work as well. There is no demo as of now, because I am still redesigning the look of my website. Sorry and I apologize.
Thanks to OcR Envy. Works in 4.2.
Just had to insert a piece of code: $fulltext=$articleinfo['pagetext'];
I have my category-ID in the URL and read the string into the widget.
Then i dont have to make a Widget for every category i use.
Greetings
Most of my articles have video instead of image, that is there is no images just youtube video, and with this widget there is no preview of youtube video [scaled] as under primary content I got now in CMS
This widget would be great if I will be able to show scaled youtube video