vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   vBulletin CMS Widgets - Widget: Latest Articles In Section (https://vborg.vbsupport.ru/showthread.php?t=232443)

OcR Envy 03-08-2010 12:10 PM

Quote:

Originally Posted by neudimenxion (Post 1999600)
hi,

The widget is not working. Already change the section id but the articles seem don't want to appear in the widget. what am i might be wrong?

Kinda Vague problem there. Let me see your widget code and the HTML it outputs.

neudimenxion 03-08-2010 10:54 PM

1 Attachment(s)
Quote:

Originally Posted by OcR Envy (Post 1999788)
Kinda Vague problem there. Let me see your widget code and the HTML it outputs.

Here is my widget code. My section id is 147 and the output is per attached.

// Set Your Section ID Here
$section = '147';
// Set The Number of Articles To Display
$limit = '2';
// 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($fulltext, 0,150);

$output .= '<left>';
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 />";
}

neudimenxion 03-08-2010 11:11 PM

Quote:

Originally Posted by OcR Envy (Post 1999788)
Kinda Vague problem there. Let me see your widget code and the HTML it outputs.

hi oCR,

Thanks for your concern. I discover what's wrong with my widget. I tick the Permission Preview in the Display Content setting. After i remove the tick it's working now. :up:

XManuX 03-09-2010 02:08 PM

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.

kingMOB 03-09-2010 03:26 PM

Thank you very much XManuX =) Will try it later.

Anyway to output the results in real time? Or at least weekly?

What about modify it to the most viewed articles? =)

justasiam 03-09-2010 10:36 PM

Is there any way to make this not display the content of the article, just the title with a link?

XManuX 03-10-2010 08:20 AM

Quote:

Originally Posted by kingMOB (Post 2000495)
Thank you very much XManuX =) Will try it later.

Anyway to output the results in real time? Or at least weekly?

What about modify it to the most viewed articles? =)

Results are updated each time you refresh the page. Using Ajax to refresh them without reloading the page could be cool but a huge backend would be required ...

To display most viewed instead of most rated, replace this :
Code:

, ".TABLE_PREFIX."cms_nodeinfo.ratingtotal
with :
Code:

, ".TABLE_PREFIX."cms_nodeinfo.viewcount
Then replace this :
Code:

ORDER BY ".TABLE_PREFIX."cms_nodeinfo.ratingtotal DESC LIMIT $limit
with:
Code:

ORDER BY ".TABLE_PREFIX."cms_nodeinfo.viewcount DESC LIMIT $limit
Replace:
Code:

$rating = $articleinfo['ratingtotal'];
with:
Code:

$views = $articleinfo['viewcount'];
And finally replace:
Code:

<span class=\"cmsrating rating{$rating}\"></span>
with:
Code:

&nbsp;Viewed $views times.

kingMOB 03-11-2010 08:29 AM

Worked perfectly, both modifications, thanks XManuX =)

kingMOB 03-12-2010 10:18 PM

I'm trying to modify the:

// Set Your Section ID Here
$section = '11';

so it recognizes the section where it is. Right now I have lots of latest, most popular and most viewed articles widgets for the various sections of my cms. Just one generic of each kind that could recognize the section where it is would make things a lot easier =)

Any help ? =)

rastaX 03-13-2010 06:05 PM

Quote:

Originally Posted by justasiam (Post 2000576)
Is there any way to make this not display the content of the article, just the title with a link?

Thanks for this, very nice. I am interested in doing this as well. I have deleted some code and it is working well, but I hate sloppiness. So if you could show the correct way, I would also appreciate it.


All times are GMT. The time now is 09:39 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01207 seconds
  • Memory Usage 1,755KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (14)bbcode_code_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete