Andreas2003 Posted February 3, 2004 Share Posted February 3, 2004 Hi there, I'm looking for a little contribution, that adds a little box in the middle of the main page (no box on the left or right side), where I can post the latest news. The whole thing should be handled through the admin section and should display up to 5 news. Can anyone give me a good and working recommendation. Thanks in advance, Regards Andreas Quote Link to comment Share on other sites More sharing options...
Guest Posted February 4, 2004 Share Posted February 4, 2004 Hi Andreas! What you want to do is similar to article and content management that I've been looking at. I decided to go with Article Manager 1.2, which allows you to manage articles and topics from within the Admin area, and uses a WSIWYG editor to post articles and images. It's a nice mod. You can download Article Manager from here: http://www.oscommerce.com/community/contri...ons,1709/page,3 The main support thread for this contribution can be found here: http://www.oscommerce.com/forums/index.php?act=ST&f=7&t=68866 The installation instructions are pretty decent and straightforward. For what you (and I) want to do - add a box with latest articles - take a look at this post from the main Article Manager thread: http://www.oscommerce.com/forums/index.php?sho...ndpost&p=291439 Copy and paste the code into a new file in the catalog/modules directory. I called it articles_latest.php to keep the naming to conform with the rest of the mod. I then went to catalog/includes/languages/english.php file and added the following defines: define('MAX_NEW_ARTICLES_PER_PAGE', '5'); define('TEXT_NEW_ARTICLES', 'Latest Articles'); To view the box, simply use an include statement wherever you want the box to appear as follows: <?php include(DIR_WS_MODULES . 'articles_latest.php'); ?> For example, you could put the above statement in index.php in place of the new product listing, or above it, below it, in other modules, etc. The contents of the box can be easily modified to return articles from a single topic just by modifying the query in articles_latest.php from $articles_new_query_raw = "select a.articles_id, a.articles_date_added, ad.articles_name, ad.articles_head_desc_tag, au.authors_id, au.authors_name, td.topics_id, td.topics_name from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_TO_TOPICS . " a2t left join " . TABLE_TOPICS_DESCRIPTION . " td on a2t.topics_id = td.topics_id left join " . TABLE_AUTHORS . " au on a.authors_id = au.authors_id, " . TABLE_ARTICLES_DESCRIPTION . " ad where a.articles_id = a2t.articles_id and a.articles_status = '1' and a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "' and td.language_id = '" . (int)$languages_id . "' order by a.articles_date_added desc, ad.articles_name"; to $articles_new_query_raw = "select a.articles_id, a.articles_date_added, ad.articles_name, ad.articles_head_desc_tag, au.authors_id, au.authors_name, td.topics_id, td.topics_name from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_TO_TOPICS . " a2t left join " . TABLE_TOPICS_DESCRIPTION . " td on a2t.topics_id = td.topics_id left join " . TABLE_AUTHORS . " au on a.authors_id = au.authors_id, " . TABLE_ARTICLES_DESCRIPTION . " ad where a.articles_id = a2t.articles_id and a.articles_status = '1' and a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "' and td.language_id = '" . (int)$languages_id . "' and td.topics_id = [B]#[/B] order by a.articles_date_added desc, ad.articles_name"; where # should be the id# of the desired topic. Tweak the table formatting a little bit, and you're done. Cheers, -C Quote Link to comment Share on other sites More sharing options...
Guest Posted May 4, 2006 Share Posted May 4, 2006 where # should be the id# of the desired topic. In case anyone else had a problem with sql errors on this as well: The id must be entered as 'number'. No hash sign. Quote Link to comment Share on other sites More sharing options...
Micke Posted July 24, 2006 Share Posted July 24, 2006 This a really sweet idea! I've been using it for a while even though It has a few issues... Has anyone out there found out how to: 1. Put it in a box [in the middle, just like new products] 2. Only show a limited number of articles on the main page [i can't get the "define('MAX_NEW_ARTICLES_PER_PAGE', '5');" to work...] This feature is so nice it deserves to be a part of the "Article Manager" contribution. //Micke Quote Link to comment Share on other sites More sharing options...
Micke Posted July 24, 2006 Share Posted July 24, 2006 Perhaps someone who actually understands php could have a look at this and tell me what it takes to make it draw that neat little box around this module like in also_purchased_products.php and so on... <?php $info_box_contents = array(); $info_box_contents[] = array('text' => TEXT_NEW_ARTICLES); new infoBoxHeading($info_box_contents, false, false); $articles_new_query_raw = "select a.articles_id, a.articles_date_added, ad.articles_name, ad.articles_head_desc_tag, au.authors_id, au.authors_name, td.topics_id, td.topics_name from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_TO_TOPICS . " a2t left join " . TABLE_TOPICS_DESCRIPTION . " td on a2t.topics_id = td.topics_id left join " . TABLE_AUTHORS . " au on a.authors_id = au.authors_id, " . TABLE_ARTICLES_DESCRIPTION . " ad where a.articles_id = a2t.articles_id and a.articles_status = '1' and a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "' and td.language_id = '" . (int)$languages_id . "' order by a.articles_date_added desc, ad.articles_name"; $articles_new_split = new splitPageResults($articles_new_query_raw, MAX_NEW_ARTICLES_PER_PAGE); if ($articles_new_split->number_of_rows > 0) { $articles_new_query = tep_db_query($articles_new_split->sql_query); echo '<table class="listing">'; while ($articles_new = tep_db_fetch_array($articles_new_query)) { $info_box_contents = array( ); echo '<tr>'; echo '<td class="smalltext"> ?<img src="/javascript/jscooktree/ThemeLibrary/page.gif" align="absmiddle">?<a href="' . tep_href_link(FILENAME_ARTICLE_INFO, 'articles_id=' . $articles_new['articles_id']) . '">' . $articles_new['articles_name']. '</a> </td>'; echo '<td class="smalltext"> ?<img src="/javascript/jscooktree/ThemeLibrary/folderopen.gif" align="absmiddle">?<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $articles_new['topics_id']) . '">' . $articles_new['topics_name'] . '</a> ? </td>'; echo '<td class="smalltext"> ?'; echo '</tr>'; } echo '</table></div>'; } else { } new infoBox($info_box_contents); ?> //Micke Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.