Back to vBulletin 4.x Add-ons

Widget: Latest Articles In Category
Mod Version: 1.6, by OcR Envy

vB Version: 4.0.0 Rating: (3 votes - 4.67 average) Installs: 38
Released: 07 Jan 2010 Last Update: Never Downloads: 0
Not Supported Auto-Template Re-usable Code Translations  

Latest Articles In Category

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

Change Log:
1.0 - Initial Release
1.1 - Updated to allow more than one category & 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 display unpublished articles.
1.5 - Updated read more link to be more vBulletin like.
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 Category Name Here)"
  • Click Save
  • Click Configure
  • Remove all the default code.
  • Copy and Paste the code below first editing $category 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 category id?
When in your article you should see something like this:
http://www.domain.comlist.php?category/11-MyCategory
The number after / in this case 11 is your category id.

Can I enter more than one category id?
Yes simply change $category = '11' to something like $category='11, 12, 13'

Code to copy(make sure you change $category and $limit!)
PHP Code:
// Set Your Category ID Here
$category '47';
// 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_category.category
     , "
.TABLE_PREFIX."cms_category.categoryid 
    , "
.TABLE_PREFIX."cms_node.setpublish
  FROM "
.TABLE_PREFIX."cms_node
INNER
  JOIN "
.TABLE_PREFIX."cms_article
    ON "
.TABLE_PREFIX."cms_article.contentid = ".TABLE_PREFIX."cms_node.contentid
INNER
  JOIN "
.TABLE_PREFIX."cms_nodeinfo
    ON "
.TABLE_PREFIX."cms_nodeinfo.nodeid = ".TABLE_PREFIX."cms_node.nodeid
INNER
  JOIN "
.TABLE_PREFIX."cms_nodecategory
    ON "
.TABLE_PREFIX."cms_nodecategory.nodeid = ".TABLE_PREFIX."cms_node.nodeid
INNER
  JOIN "
.TABLE_PREFIX."cms_category
    ON "
.TABLE_PREFIX."cms_category.categoryid = ".TABLE_PREFIX."cms_nodecategory.categoryid
 WHERE "
.TABLE_PREFIX."cms_category.categoryid IN ($category)
   AND ("
.TABLE_PREFIX."cms_node.setpublish != 0)
ORDER 
    BY "
.TABLE_PREFIX."cms_node.publishdate DESC LIMIT $limit
"
);

while(
$articleinfo vB::$db->fetch_array($articlegrab)) {

    
$title $articleinfo['title'];
    
$image $articleinfo['previewimage'];
    
$text $articleinfo['previewtext'];
    
$nodeid $articleinfo['nodeid'];
    
$url $articleinfo['url'];
    
$unixdate $articleinfo['publishdate']; 
    
$date date("F j, Y, g:i a"$unixdate);  
    
$fulltext strip_bbcode($fulltext);
    
$text preg_replace('/\[ATTACH\=CONFIG\]\d\d\[\/ATTACH\]/'''$text);
    
$text strip_bbcode($text);


   if(
$text == ''$text substr($fulltext0,150);
    
    
$output .= '<center>';
    if(
$image != ''$output .= "<img src='".$image."' width='".$width."px' height='".$height."px' /><br />";
    
    
$output .= "<a href='content.php?".$nodeid."-".$url."'>".$title."</a><br /><p>Publish Date: ".$date."</p></br></center><p>".$text." <a href='content.php?".$nodeid."-".$url."'>Read More <img alt='Read More' src='images/cms/read_more-right.png' title='Read More' border='0'></a></a></p><br />";

Preview:


For Section Mod See Here:
http://www.vbulletin.org/forum/showthread.php?p=1949493

Download

No files for download.

Screenshots

Click image for larger version
Name:	screenshot.PNG
Views:	2231
Size:	128.1 KB
ID:	112093  


vblts.ru supports vBulletin®, 2022-2024