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 ");
Hi,
whats the 150px image for?
It also seems like that the preview text code does not work
Preview Text works fine for me on two of my test boards. Check your source and see paste the HTML the widget enters so I can look at it closer please. The 150px image is the preview image for the article. If you insert and image into the article it will display a thumbnail view of the image. You can change the dimensions if you'd like. 150px just worked for what I was trying to do.
Quote:
Originally Posted by kingMOB
OcR Envy, there's a way to print the section, subsection and/or categories from the article in the widget?
Thanks =)
No king not currently.
Quote:
Originally Posted by tazattitude
I also got an error.
I changed the section to one of my sections
HTML Code:
Parse error: syntax error, unexpected $end in /usr/www/users/saj716/a_customxxxxxxxxx/forum/packages/vbcms/widget/execphp.php(171) : eval()'d code on line 44
Also, to add, I do have a prefix "vbull"
You must change the sections to match your own section numbers. Make sure you have the number reading like this $section = '115'; 115 would be your own section id but you must have the surrounding ' '; for it to work.
Quote:
Originally Posted by Spiritvn
Could u make it automatically get the section ID from the section clicked?
what section id if have to put in when i want to have articles from the main section - for example at vbulletin.com it is called "the Front page" ? that i get a lot of articles - because i tried the section id and i get nothing displayed ?!
You must change the sections to match your own section numbers. Make sure you have the number reading like this $section = '115'; 115 would be your own section id but you must have the surrounding ' '; for it to work.
That's what I mean by
"I changed the section to one of my sections"
PHP Code:
// Set Your Section ID Here
$section = '28'; // This is a live section on my website (id: 28). Permissions to view granted to all usergroups
// Set The Number of Articles To Display
$limit = '3';
$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.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
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))
ORDER BY ".TABLE_PREFIX."cms_node.publishdate DESC LIMIT $limit ");
what section id if have to put in when i want to have articles from the main section - for example at vbulletin.com it is called "the Front page" ? that i get a lot of articles - because i tried the section id and i get nothing displayed ?!
You can do this by default...
Admin Panel
Widgets>>Create New Widget >>Choose "General Search" (also name your widget)
Then "save"
Then you need to configure. Choose "Article". Then choose the rest how many days and how many you want to show up.
That's what I mean by
"I changed the section to one of my sections"
PHP Code:
// Set Your Section ID Here $section = '28'; // This is a live section on my website (id: 28). Permissions to view granted to all usergroups // Set The Number of Articles To Display $limit = '3';
$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.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 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)) ORDER BY ".TABLE_PREFIX."cms_node.publishdate DESC LIMIT $limit ");
Admin Panel
Widgets>>Create New Widget >>Choose "General Search" (also name your widget)
Then "save"
Then you need to configure. Choose "Article". Then choose the rest how many days and how many you want to show up.
This will show every section though. To show just the front page set $section = '1';
I know this isn't available currently, but any thought to setting it up so that individual users could choose the section they want to appear by default? In other words, setting up a widget on the front page that would show articles by section based on their selection?
I know this isn't available currently, but any thought to setting it up so that individual users could choose the section they want to appear by default? In other words, setting up a widget on the front page that would show articles by section based on their selection?
Not something I'm going to work on but that's fairly easily done on your end.
Create a User Profile Field, Single Line Textbox.
In the UsersCP have the user enter the Section ID they want to display.
In the widget change $section = ' '; to $section = $bbuserinfo['fieldX']
X would be the Profile Field #. I believe this will work I obviously haven't tested it.