View Full Version : v3Article Module - Last 10 Articles
maximux1
06-17-2004, 03:55 PM
This CMPS module uses the excellent v3Article system developed by John Warwick. The module displays the 10 most recent articles submitted, in DESC order, (Last article submitted is first in list).
This module also includes the author of the article with a link to his pubilc profile and how many views the article has had.
You can vie the module in action on the right hand side of http://www.marijuana.com - the module is titled "The Magazine".
http://www.marijuana.com
You'll need to upload the php file to your modules directory and create two new templates named "adv_portal_articles" & "adv_portal_articlesbits". Add the contents of the respective text files to the new templates and save. Next, create the new module using the drop down menu selecting "cmps-articles.php". In the "templates used" field enter the following templates.
adv_portal_articles,
adv_portal_articlesbits
Dont forget to update your index pages(s) to show the new module.
Special thanks to wcbryant, who's help has shed new light on vB development for me. Im very grateful for your code additions and help.
Maximux1
Marijuana.Com
Shack Networks
06-17-2004, 05:32 PM
lol
U bugger you beat me too it:)
V nice addon m8
Thanks a lot for this your a star.
H
Shack Networks
06-17-2004, 05:41 PM
I am getting a parse error on line 41 ?
maximux1
06-17-2004, 05:49 PM
I am getting a parse error on line 41 ?
Make sure there is no white space after the ending ?>
Sometimes that will cause the error you are speaking of. My file only has 41 lines...
Let me know if you would like for me to re-upload the working version that is on my site.
Max
p.s. Heh, I figured someone was banging away at that - there's a ton more to be done, though. See my more general thread about v3articles (http://www.vbadvanced.com/forum/showthread.php?t=1356)
Shack Networks
06-17-2004, 05:52 PM
Nope no white spaces Please can you upload yours and I will give that a try.
H
maximux1
06-17-2004, 06:02 PM
I've uploaded a new package - could you please give that a try for me? Should just have to overwrite cmps-articles.php in the mods dir.
thanks!
Shack Networks
06-17-2004, 06:09 PM
Ok that worked fine, I had to alter the table name to add the prefix though
/* Performing SQL query */
$result = $DB_site->query("SELECT articleid, title, commentcount, articleusername, articleuserid, views FROM vb3_article ORDER BY articleid DESC LIMIT 10");
Its working just fine now though thanks :)
H
maximux1
06-17-2004, 06:10 PM
ah, good point, didnt think about table prefix users -
I'll fix that and updated the original file.
Thanks for pointing that out and your help!
Max
Shack Networks
06-17-2004, 06:14 PM
Hey No Probs, thanks for the hack :)
I am gonna add this together with the featured article hack and combine them into one nice block for the center, I will post it up when and if I get it fone :)
H
maximux1
06-17-2004, 06:17 PM
Hey, that sounds like a great idea! Looking forward to it :)
btw, i've updated the original package to support table prefix's and that parse error.
Max
maximux1
06-17-2004, 07:04 PM
Script has been edited to no longer show articles waiting to be moderated.
Max
Shack Networks
06-18-2004, 05:12 AM
OK I was gonna merge both hacks together into one PHP script but realised that the authors may not like that too much so I decided to go via the templates route and add them together in one block.
I came up with the block bellow, if anyone wants to know how to do it then I will gladly sort out some instructions and post up my templates etc...
I am gonna play about with it later today and make it look a bit nicer but at the moment this is active on my site and fully functional. I would love it however if the featured article script could be made to display the first image [Thumbnailed] in the aricle thread in the block as this would be the icing on the cake for me.
Remember its not too complex to acomplish but I would sooner both autors merge thier hacks together and works as one as this is one nice little addition .
OH BTW MaxiMux your site is kewl m8, /me heads off for a smoke :)
H
ixian
06-21-2004, 04:59 AM
Maximux1, thanks for the excellent addon. Nice site, btw.
If you don't mind me asking, what did you need to do to get the articles themselves integrated with VBA CPMS? I notice all your articles have your left sidebar present when viewing rather than taking up the entire page; I am trying to do the same myself. Any pointers?
Thanks again.
maximux1
06-21-2004, 10:45 AM
Thanks, ixian -
Well - I guess Im not exaclty sure what you're talking about. I have made some changes over the weekend and slightly modified the frontpage so it may be different that what you were speaking of.
Be sure to read the instructions carefully. Once you have the module created you can move it anywhere you like on the page using the vBa CMPS module editior.
Happy to help further if I can.
Max
ixian
06-21-2004, 01:24 PM
No no, I'm not talking about your module - I'm talking about the article addon itself. You appear to have modified it.
What I mean is, when I read the full article, like, say, this one:
http://www.marijuana.com/420/article.php?a=11
You have the vba CPMS left sidebar still showing, with your main menu, etc, blocks. The normal Articles addon doesn't do that. I was wondering what you changed.
Thanks!
maximux1
06-21-2004, 01:54 PM
oh oh oh - sorry, I get what you mean, now.
What I did was first, create a new page in vBa CMPS - call it whatever you like, for the page identifier, I used "magazine" - again, use whatever you like.
Once you have created the new page in CMPS, you'll need to edit article.php, like so...
At the very bottom of article.php you will find the following two lines...
// articles main page eval
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('ARTICLES') . '");');
Replace those two lines with the following lines;
eval('$HTML = "' . fetch_template('ARTICLES') . '";');
print_portal_output($home, $HTML);
Now, your articles will be displayed within the scope of vBa CMPS.
ixian
06-21-2004, 02:02 PM
Huh. Clearly I am doing something wrong.
I created a new page in CMPS, called it magazine just for testing, added the file edits, now I get a blank page for article.php.
I think the instructions above are missing something? How does that tell article.php to use the new CMPS page?
ixian
06-21-2004, 02:04 PM
Update: The error message I get when I turn on error messages in php is:
Fatal error: Call to undefined function: print_portal_output() in /var/www/html/forums/article.php on line 1291
Which makes sense, because that doesn't appear to be an existing function. What am I missing?
maximux1
06-21-2004, 02:31 PM
ah - I forgot to have you add the following code to the TOP of article.php
<?
define('VBA_PORTAL', true);
define('VBA_PAGE', 'magazine');
...
maximux1
06-21-2004, 02:33 PM
Add those two lines to the top of article.php and that should fix ya up.
Let me know if your still having problems.
max
ixian
06-21-2004, 03:06 PM
That did the trick, thanks!
I knew something was missing:)
maximux1
06-21-2004, 03:09 PM
You bet, sorry bout that, bro - trying to answer in too big a hurry.
Max
renderst
06-21-2004, 08:52 PM
hm works great, but there are some broken images: for example: the gradients and the thumbnail are broken!
FleaBag
06-22-2004, 03:40 PM
Having some trouble with this... The title of the module appears but none of the content.
jaliam
06-22-2004, 06:21 PM
It does not work for me. Although I changed the prefix, it still would not display on my main page. I will try to alter the article.php file and see if that will fix it.
jaliam
06-22-2004, 06:26 PM
Here is the error code I've been getting, all!
Database error in vBulletin 3.0.1:
Invalid SQL: SELECT articleid, title, commentcount, articleusername, articleuserid, views
FROM vb3_article ORDER BY articleid DESC LIMIT 10
mysql error: Table 'bibletr_forums.vb3_article' doesn't exist
mysql error number: 1146
Date: Tuesday 22nd of June 2004 06:23:24 PM
Script: http://www.bibletruths.us/
Referer: http://www.bibletruths.us/forums/forumdisplay.php?s=&daysprune=&f=25
Can somebody please tell me how to make this module collapsable like the mod at http://www.vbadvanced.com/forum/showthread.php?t=1044 does?
FleaBag
06-25-2004, 09:37 AM
This still doesn't work, I would appreciate it if someone could help me out.
jaliam
06-25-2004, 10:38 AM
This is the error I am getting now.
Parse error: parse error in /home/bibletr/public_html/forums/modules/cmps-articles.php on line 4
Here is my PHP code:
<?php
/* Performing SQL query */
$result = $DB_site->query("SELECT articleid, title, commentcount, articleusername, articleuserid, views FROM vb3_article ORDER BY articleid DESC LIMIT 10");
WHERE open = '1' ORDER BY articleid DESC LIMIT 10");
// loop through the reults of the query
while($result_array = mysql_fetch_array($result)) {
$title = $result_array["title"];
$articleid=$result_array["articleid"];
$username=$result_array["articleusername"];
$userid=$result_array["articleuserid"];
$commentcount=$result_array["commentcount"];
$views=$result_array["views"];
// $string .= "<li><a href=$vboptions[bburl]/article.php?a=$articleid>$title</a> <font size=-2 color=gray>by <a href=$vboptions[bburl]/member.php?userid=$userid>$username</a> ($views views)</font>";
$getbgrow = getrowcolor();
eval('$articlesbits .= "' . fetch_template('adv_portal_articlesbits') . '";');
}
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_articles') . '";');
?>
Your help would be greatly appreciated! :cool:
maximux1
06-25-2004, 01:36 PM
This is the error I am getting now.
Here is my PHP code:
<?php
/* Performing SQL query */
$result = $DB_site->query("SELECT articleid, title, commentcount, articleusername, articleuserid, views FROM vb3_article ORDER BY articleid DESC LIMIT 10");
WHERE open = '1' ORDER BY articleid DESC LIMIT 10");
// loop through the reults of the query
while($result_array = mysql_fetch_array($result)) {
$title = $result_array["title"];
$articleid=$result_array["articleid"];
$username=$result_array["articleusername"];
$userid=$result_array["articleuserid"];
$commentcount=$result_array["commentcount"];
$views=$result_array["views"];
// $string .= "<li><a href=$vboptions[bburl]/article.php?a=$articleid>$title</a> <font size=-2 color=gray>by <a href=$vboptions[bburl]/member.php?userid=$userid>$username</a> ($views views)</font>";
$getbgrow = getrowcolor();
eval('$articlesbits .= "' . fetch_template('adv_portal_articlesbits') . '";');
}
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_articles') . '";');
?>
Your help would be greatly appreciated! :cool:
The parse error is because that SQL statement, it's broken...Try this codes...
<?php
/* Performing SQL query */
$result = $DB_site->query("SELECT articleid, title, commentcount, articleusername, articleuserid, views FROM vb3_article WHERE open = '1' ORDER BY articleid DESC LIMIT 10");
// loop through the reults of the query
while($result_array = mysql_fetch_array($result)) {
$title = $result_array["title"];
$articleid=$result_array["articleid"];
$username=$result_array["articleusername"];
$userid=$result_array["articleuserid"];
$commentcount=$result_array["commentcount"];
$views=$result_array["views"];
// $string .= "<li><a href=$vboptions[bburl]/article.php?a=$articleid>$title</a> <font size=-2 color=gray>by <a href=$vboptions[bburl]/member.php?userid=$userid>$username</a> ($views views)</font>";
$getbgrow = getrowcolor();
eval('$articlesbits .= "' . fetch_template('adv_portal_articlesbits') . '";');
}
eval('$home[$mods[\'modid\']][\'content\'] .= "' . fetch_template('adv_portal_articles') . '";');
?>
jaliam
06-25-2004, 03:05 PM
Ok, I tried using that code but now I could not access my index page. This is what I am getting now...
Database error in vBulletin 3.0.1:
Invalid SQL: SELECT articleid, title, commentcount, articleusername, articleuserid, views FROM vb3_article WHERE open = '1' ORDER BY articleid DESC LIMIT 10
mysql error: Table 'bibletr_forums.vb3_article' doesn't exist
mysql error number: 1146
IndyWebDesign
06-25-2004, 03:39 PM
Ok, my question is how hard would it be to offer a vBadvanced version? I've upgraded to CMPS but I found it too time consuming to covert over all my blocks, etc so I removed it and plan to stick with vBadvanced.
FleaBag
06-28-2004, 11:11 AM
I thought I'd attach a screenshot of my problem incase anyone is able to identify the problem.
maximux1
06-28-2004, 12:19 PM
Anyone who is still having problems with this module should undo any changes they have made up to this point and just download the updated zip file. I think some of the problems are stemming from 2 different versions of this hack that were posted.
If you have problems after starting from scratch and reading the instructions twice please post here and I will do what I can to help out.
Max.
FleaBag
06-28-2004, 12:22 PM
Downloaded and re-installed, still exactly the same problem as the screeny. :(
maximux1
06-28-2004, 12:52 PM
Flea, one quick questions;
You do have articles in loaded into the article tables, correct?
EDIT Can you post the URL to your site?
FleaBag
06-29-2004, 12:20 AM
Yes I have a few articles in there mate.
It's www.dragonninja.co.uk - thanks.
mholtum
06-29-2004, 01:33 AM
I tried it, but got this error
Database error in vBulletin 3.0.1:
Invalid SQL: SELECT articleid, title, commentcount, articleusername, articleuserid, views
FROM article
WHERE open = '1'
ORDER BY articleid DESC LIMIT 10
mysql error: Table 'mholtum_forum.article' doesn't exist
mysql error number: 1146
Date: Tuesday 29th of June 2004 12:31:59 AM
Script: http://www.ravensrealm.net/
Referer:
Username: mholtum
IP Address: 68.99.209.240
maximux1
06-30-2004, 05:20 PM
mholtum:
mysql error: Table 'mholtum_forum.article' doesn't exist
does the article table exist in your database? And, does it use the db_prefix of 'mholtum_forum?
Flea:
Could you please post the contents of the following two templates, please?
adv_portal_articles,
adv_portal_articlesbits
Max
FleaBag
06-30-2004, 09:22 PM
As requested...
adv_portal_articles
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td class="tcat"><span class="smallfont"><strong>$vba_options[portal_blockbullet] Recent Articles</strong></span></td>
</tr>
$articlesbits
</table>
<br />
adv_portal_articlebits
<tr>
<td class="$getbgrow" width="100%">
<li><span class="smallfont"><b><a href=$vboptions[bburl]/article.php?a=$articleid>$title</a></b><br>Author: <a href=$vboptions[bburl]/member.php?userid=$userid>$username</a><br><font color="#5f5f5f">$views views</font></span>
</td>
</tr>
Thanks for your continued help. :)
maximux1
07-01-2004, 12:36 AM
As requested...
Thanks for your continued help. :)
is that template named adv_portal_articlebits or adv_portal_articleSbits?
The template must be named 'adv_portal_articlesbits'. Hope we found it - if not, let me know.
Max
FleaBag
07-02-2004, 11:17 AM
You are a gem, it works now. I feel rather stupid, I had briefly though of that myself but thought I'd checked and it was correct lol. All working now, thanks for your help and patience.
maximux1
07-02-2004, 12:18 PM
:) Glad we got it worked out.
Enjoy!
mholtum
07-02-2004, 01:16 PM
mholtum:
does the article table exist in your database? And, does it use the db_prefix of 'mholtum_forum?
Max
my db is mholtum_forum
How to make the articles table?
maximux1
07-03-2004, 11:04 PM
my db is mholtum_forum
How to make the articles table?
Ah, ya - that'll do it too.
the articles table is created when you install the fine v3articles system available at vb.org. This mod is useless without first installing that system, as this simply an add-on to the system.
Max
mholtum
07-04-2004, 02:35 AM
Ah, ya - that'll do it too.
the articles table is created when you install the fine v3articles system available at vb.org. This mod is useless without first installing that system, as this simply an add-on to the system.
Max
Oh now you tell me! ;)
SmasherMaster
07-07-2004, 02:13 PM
Very ncie modification, but could you make it so that the Latest Threads options in "edit a page" or "Create a new page" are in the modification? I would like the catagory the articles are displayed in and a specific number of articles displayed as well. Would be nice if you could do that thanks! :D
Could anyone edit this hack to show most both top 10 read and 10 latest articles ?
Amavisca
11-15-2004, 06:00 PM
I think for top read you would replace to" Order views" in the php file, right?
I need help on another thing though, I would like to pull articles from one particular category (not from all of them). How do I do that? Thank you in advance!
dnoyeb2002
12-06-2004, 03:02 PM
I think for top read you would replace to" Order views" in the php file, right?
I need help on another thing though, I would like to pull articles from one particular category (not from all of them). How do I do that? Thank you in advance!
I second the thought of pulling from a specific category (as I have reviews, artists, and articles). Let me know if its possible . . .
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.