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 Section Details »»
Widget: Latest Articles In Section
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: 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
"
);


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."'> <img alt='Read More' src='images/cms/read_more-right.png' title='Read More' border='0'></a></p><br />";

Preview:



For Category Mod See Here:
https://vborg.vbsupport.ru/showthread.php?t=232440

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.
3 благодарности(ей) от:
case-dk, Oxylis, Toorak Times

Comments
  #32  
Old 02-06-2010, 03:27 PM
fer_75 fer_75 is offline
 
Join Date: Jun 2007
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The great thing would be to have the latest articles in the current section automatically detected, without to specify $section = 'x'; ... It would be amazing if $section=current section detected.

Would be this possible ?
Reply With Quote
  #33  
Old 02-07-2010, 11:04 AM
iamspookysdaddy iamspookysdaddy is offline
 
Join Date: Jun 2007
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Seems like a mod i need thanks! Is there any way to control what user groups see the widget or not? I would like uno-logged in users to see block with certain articles but if you log in you will not see it.

Please advise....
Reply With Quote
  #34  
Old 02-07-2010, 05:18 PM
Neptun Neptun is offline
 
Join Date: Aug 2003
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Neptun View Post
i get the widget working now

but there are 2 things what i need to know:

1.) when i click on the "(more)" link in the widget - nothing is working i get nothing displayed ?! (i think the problem is with seo - how can i fix this in the widget in the rest of the cms everything is working with seo .. please help )

2.) how can i display the showed articels side by side in one row ?!

this would be great if i get this things working

really a great hack

CAN SOMEBODY HELP ME WITH THIS 2 POINTS ?!
Reply With Quote
  #35  
Old 02-09-2010, 10:53 AM
OcR Envy's Avatar
OcR Envy OcR Envy is offline
 
Join Date: May 2008
Location: Boston
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Demo16 View Post
I like it very much, but I would like to put some div there to use some css in order to make some changes (like floating the img to the left and the text on the right).

There's a way to do this?
Find:

PHP Code:
    $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."'>(more)</a></p><br />"
Replace with something like this:

PHP Code:
    $output .= '<div style="float: right; width:255px;">';
    if(
$image != ''$output .= "<img src='".$image."' width='".$width."px' height='".$height."px' style="floatleft;" /><br />";
    
$output .= "<a href='content.php?".$nodeid."-".$url."'>".$title."</a><br /><p>Publish Date: ".$date."</p></br><p>".$text." <a href='content.php?".$nodeid."-".$url."'>(more)</a></p><br /></div>"
Quote:
Originally Posted by Neptun View Post
i get the widget working now

but there are 2 things what i need to know:

1.) when i click on the "(more)" link in the widget - nothing is working i get nothing displayed ?! (i think the problem is with seo - how can i fix this in the widget in the rest of the cms everything is working with seo .. please help )

2.) how can i display the showed articels side by side in one row ?!

this would be great if i get this things working

really a great hack
1. I would have to know what your vbSEO url structure is. Give me some example links to articles or provide me a link to your website.

2. Remove the <center> calls and make a <table><tr><td> would be easiest. It's just simply HTML

Quote:
Originally Posted by fer_75 View Post
The great thing would be to have the latest articles in the current section automatically detected, without to specify $section = 'x'; ... It would be amazing if $section=current section detected.
Would be this possible ?
Hmmn how would this be useful? If they are already in the section it would show the latest articles on the section page?

Quote:
Originally Posted by iamspookysdaddy View Post
Seems like a mod i need thanks! Is there any way to control what user groups see the widget or not? I would like uno-logged in users to see block with certain articles but if you log in you will not see it.
Please advise....
At the very top of your widget add:
PHP Code:
if($show['guest']) { 
And at the bottom add:
PHP Code:

Reply With Quote
  #36  
Old 02-09-2010, 05:44 PM
Neptun Neptun is offline
 
Join Date: Aug 2003
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OUTPUT

when i change the <center> to <table><tr><td> - i have no changes .... the articles in the widget have the same style not side by side in one row ....

the code is now - this is everything what i have change in the whole code of the widget from you

Quote:
if($text == '') $text = substr($fulltext, 0,150);

$output .= '<table><tr><td>';
if($image != '') $output .= "<img src='".$image."' width='".$width."px' height='".$height."px' /><br />";

$output .= "<a href='content.php?".$nodeid."-".$url."'>".$title."</a><br /></table></tr></td><p>".$text." <a href='content.php?".$nodeid."-".$url."'>(more)</a></p><br />";
}
then i get this output -> see the 1st picture

but it should look like the 2nd picture (after widget.jpg)


SEO URLS

CMS Section Articles List: portal/section/[section_id]-[section_title]-list.html

CMS Section Articles List Pagination: portal/section/[section_id]-[section_title]-page[page].html

this is my url rewrite style for the articles in the cms
Attached Images
File Type: jpg before widget.jpg (111.6 KB, 0 views)
File Type: jpg after widget.jpg (109.3 KB, 0 views)
Reply With Quote
  #37  
Old 02-10-2010, 02:50 PM
DivineMessenger DivineMessenger is offline
 
Join Date: Feb 2008
Posts: 200
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can this be used to turn all posts from a certain section into articles for my news page on the cms?
Reply With Quote
  #38  
Old 02-10-2010, 03:49 PM
OcR Envy's Avatar
OcR Envy OcR Envy is offline
 
Join Date: May 2008
Location: Boston
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by DivineMessenger View Post
can this be used to turn all posts from a certain section into articles for my news page on the cms?
Eh no, you'll need to use the Promote to Article function.


Quote:
Originally Posted by Neptun View Post
OUTPUT

when i change the <center> to <table><tr><td> - i have no changes .... the articles in the widget have the same style not side by side in one row ....

the code is now - this is everything what i have change in the whole code of the widget from you



then i get this output -> see the 1st picture

but it should look like the 2nd picture (after widget.jpg)


SEO URLS

CMS Section Articles List: portal/section/[section_id]-[section_title]-list.html

CMS Section Articles List Pagination: portal/section/[section_id]-[section_title]-page[page].html

this is my url rewrite style for the articles in the cms

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
"
);


$output .= '<table><tr>';

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


   if(
$text == ''$text substr($fulltext0,150);
    
    
$output .= '<td><center>';
    if(
$image != ''$output .= "<img src='".$image."' width='".$width."px' height='".$height."px' /><br />";
    
    
$output .= "<a href='/portal/".$url .'-'.$nodeid."/'>".$title."</a><br /><p>Publish Date: ".$date."</p></br></center><p>".$text." <a href='/portal/".$url .'-'.$nodeid."/'>(more)</a></p></td>";
}  

$output .= '</tr></table>'
Just a guess on the url rewrite. I actually need the format for your CMS Entry setting in vbSEO.
Reply With Quote
  #39  
Old 02-10-2010, 08:39 PM
Neptun Neptun is offline
 
Join Date: Aug 2003
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Perfect works good now - but i have a little thing with the text descriptions under the pictures now -> you see it in the attachment ..

There is no space between the text of each displayed articel in the widget - is there de possibility to do a maximum number of charters and the rest with "..." and then the "(more)" function like in the attachment with the number "2" -> this would be great if i can get this output then the widget is perfect - or if this not possible then the "1" would be also good - but "2" would be the best

and how can i change the text size in the description?

Is there a possibility to but the "Read more ->" like in the cms used with the articel previes instead of the "(more)" - thats just a idea to look more professional ...


Thx for your great help i love your widget hack


with the seo i have it working now your idea was right
Attached Images
File Type: jpg Widget.jpg (107.1 KB, 0 views)
Reply With Quote
  #40  
Old 02-11-2010, 11:45 AM
OcR Envy's Avatar
OcR Envy OcR Envy is offline
 
Join Date: May 2008
Location: Boston
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There are two solutions to the spacing problem neptun.

You could either add cellpadding="10px" or something to <table> or a style="padding-right:10px;" to the <td>

Or to shrink the text displayed find:
PHP Code:
if($text == ''$text substr($fulltext0,150); 
and edit the 150 to whatever number of characters you'd like. However this might not work if the article is pulling the previewtext from the database it wouldn't be effected by this change.


For the more idea:

find:

PHP Code:
(more)</a
change to:

PHP Code:
Read More <img alt='Read More' src='images/cms/read_more-right.png'  title='Read More' border='0'></a
I like the idea to I'll update the original code
Reply With Quote
  #41  
Old 02-11-2010, 09:05 PM
Neptun Neptun is offline
 
Join Date: Aug 2003
Posts: 113
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanksss that you like my idea

i have changed the code now with the "read more" instead of the "(more) and have put a little center & b to this - a change the text size of the discription - it looks really perfect now

perfect hack now its perfect for me and it looks really professional now

thx for your help
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 12:23 PM.


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.05561 seconds
  • Memory Usage 2,441KB
  • Queries Executed 26 (?)
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
  • (9)bbcode_php
  • (9)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
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (3)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (4)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • 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