Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Widget: Latest Articles In Category Details »»
Widget: Latest Articles In Category
Version: 1.6, by OcR Envy OcR Envy is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Category: vBulletin CMS Widgets - Version: 4.0.0 Rating:
Released: 01-06-2010 Last Update: Never Installs: 38
Auto-Templates
Re-useable Code Translations  
No support by the author.

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:
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:
https://vborg.vbsupport.ru/showthread.php?p=1949493

Screenshots

File Type: png screenshot.PNG (128.1 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 06-01-2010, 01:23 PM
kingMOB kingMOB is offline
 
Join Date: Nov 2007
Posts: 69
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi OcR Envy,

is there a way to the widget show articles that only matchs two categories?

Something like $category = '17(but have to be in the category 49 as well),66(but have to be in the 49 category as well),67(but have to be in the 49 category as well)';

Thanks =)
Reply With Quote
  #23  
Old 06-23-2010, 09:29 PM
NJMane NJMane is offline
 
Join Date: Jun 2010
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If i only want the TITLE of the article to show up in the widget how would i make that happen. I dont want any of the extra stuff (i.e. pictures, publish date, article text, etc.). Thanks.
Reply With Quote
  #24  
Old 07-18-2010, 05:02 PM
Macindy Macindy is offline
 
Join Date: Dec 2003
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi there!

I want to show articles only which are not in a category, so I used NOT IN
But, what if the article have more categories, so now the query adds it so often how categories are there. e.g. the article have categorieids = 1,30,24
And now I say NOT IN 24 - now it shows two times, because it is not in 1 and not in 30.

Can somebody help me?
Reply With Quote
  #25  
Old 12-15-2010, 08:48 PM
dang3rzon3 dang3rzon3 is offline
 
Join Date: Sep 2009
Location: Milano (Italy)
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

doesn't work with vbseo.

Exaple of link:

http://www.pianetagay.com/forum/cont...-pompieri.html
http://www.pianetagay.com/forum/cont...clericali.html
Reply With Quote
  #26  
Old 05-16-2011, 03:57 PM
BadGuy's Avatar
BadGuy BadGuy is offline
 
Join Date: Nov 2002
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Till now still no preview text
Reply With Quote
  #27  
Old 08-31-2011, 08:12 PM
stopchan stopchan is offline
 
Join Date: Jun 2010
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BadGuy View Post
Till now still no preview text
For me too

And thumbnail proportions (heigh to width) doesn't much original image proportions. Thumbnail fits to defined into widget thumbnail height/width.
Reply With Quote
  #28  
Old 10-04-2011, 09:51 AM
inigo inigo is offline
 
Join Date: May 2010
Location: Spain
Posts: 102
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am using random category,

$category = rand(1,15);

Each time (impression) the first articles of one category will be printed.

but I would like to print at the top of the widget (before the articles) the name (title) of the category, do you know how to do this?

Thanks,
Reply With Quote
  #29  
Old 11-02-2011, 02:42 PM
S S0DEN's Avatar
S S0DEN S S0DEN is offline
 
Join Date: Jul 2006
Location: Ft Carson
Posts: 52
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

does not work 4.1.7
Reply With Quote
Reply


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 01:53 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05027 seconds
  • Memory Usage 2,337KB
  • Queries Executed 24 (?)
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
  • (1)bbcode_php
  • (2)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
  • (2)pagenav_pagelink
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (1)postbit_attachment
  • (9)postbit_onlinestatus
  • (9)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • 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