Dynamic external content for your Joomla site. | IT Admins Group
 

Dynamic external content for your Joomla site.

Spread the love

Seeing as how IT Admins is still a very young site I was looking for a way to add content/articles without having to write them myself and without a large community to submit them. I found the AutoArticles 3000 component in the Extensions archive on the Joomla website, and thought it would be perfect for my needs. Unfortunately not.

After installing the component I found out that you have to create a menu link to the component. Only then can you see the Catagories that you selected during installation/configuration with the Story/Article titles. This isn't what I wanted. I wanted content right on the front of my site.

So I started looking at the com_a3000 package and made a few changes….

To get what I needed I had to make a few changes in how AA3000 was installed. These steps are not for the faint of heart so YOU take responsibility for any problems you may encounter. This is a VERY rough hack and I will update it later (when I have a bit of time to really take a look at the Joomla core).

1. copy pagination.inc.php from the com_a3000 component directory to the joomla_base/modules directory

2. You will need a mod_a3000.php file. See listing below.

3. create the menu link to the a3000 component as usual (Menu >> main menu >> new).

4. write down the Itemid portion of the link from step 3.

5. for this step copy an existing site module (modules >> site modules). I used the mod_html site module in this case. I just made a copy of the existing site module, selected where I want it displayed (I choose top) and saved it with the title of "Other News".

6. Open up your Joomla DB in phpMyAdmin (is easiest) and select the #_modules table.

7. Browse the table until you find the "Other News" module you created in step 5.

8. Edit the entry. Change the module name to mod_a3000 (in my case mod_html to mod_a3000) and change the parameters to "Itemid=##". ## = the Item id from step 4 (in my case Itemid=57) . Then save it.

mod_a3000.php listing:

{geshibot lang="php"}<?php
/**
* @version 1.0.0
* @package AutoArticles 3000
* @copyright (C) 2006 Csaba Kissi
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*
* Modified for use as main page module by
* Charles Williams
* http://www.itadmins.net
*
*/
 
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or
    die( 'Direct Access to this location is not allowed.' );
 
// handle the task
$task = mosGetParam( $_REQUEST, 'task', '' );
$id = mosGetParam( $_REQUEST, 'id', '' );
$from = mosGetParam( $_REQUEST, 'from', '1' );
$sort = mosGetParam( $_REQUEST, 'sort', '' );
$module_name = mosGetParam( $_REQUEST, 'option', '' );
$option = $module_name;
$terms = mosGetParam( $_REQUEST, 'terms', '' );
$srch_type = mosGetParam( $_REQUEST, 'srch_type', '' );
$type = mosGetParam( $_REQUEST, 'type', '' );
$search = mosGetParam( $_REQUEST, 'search', '' );

$a3000_url = "http://www.articles3000.com";
$maxarticles = 20;

function show_mod_categories() {
global $database;
   $articles = Array();
   $sql = "SELECT id, name FROM #__a3000_categories WHERE is_active=1 ORDER BY name";
   $database->setQuery( $sql ); 
   $categories = $database->loadObjectList();
   foreach($categories as $category) {    
      $cat_id = $category->id;
      $cat_name = $category->name;
      $sql = "SELECT a.id,a.title,a.description,a.cat_id,b.name as cat_name "
            ."FROM #__a3000_articles as a "
            ."LEFT JOIN #__a3000_categories as b ON a.cat_id = b.id "  
            ."WHERE a.cat_id = '$cat_id' "
            ."ORDER BY a.pub_date DESC "
            ."LIMIT 0,3";
     $database->setQuery( $sql );       
     $articles1 = $database->loadObjectList();
     foreach($articles1 as $article) {
       array_push($articles,$article);
     } 
   }
   echo "<table width=100% border=0 cellspadding=2 cellpadding=0>" ;  
   for($i=0;$i<count($articles);$i++) {    
     $article = $articles[$i];      
     if(($old_cat_name != $article->cat_name) || (!isset($old_cat_name))) {
         $old_cat_name = $article->cat_name;
         if ($cnt % 2 == 0) {             
             if($cnt != 0)   echo "</table></tr>";        
             echo "<tr><td width=50% valign=top>";
         }   
         if ($cnt % 2 != 0) echo "</table></td><td width=50% valign=top>";                   
         $cnt ++;        
         echo "<table width=100% border=0 cellpadding=0 cellspacing=1>";
         echo "<tr>
         <td class=sectiontableheader>
         <b>".$article->cat_name."</b>
         </td></tr><tr><td>
         <img src='/images/pix.gif' height=2>
         </td></tr>";
         echo "<tr><td bgcolor='$bgcolor3' valign=middle align=right>
         &nbsp;<a href='/index.php?option=com_a3000&task=showcategory&id=".$article->cat_id."'>more…</a>
         </td></tr>";
         echo "</table>";
         echo "<table border=0>";
     }
     echo "<tr><td>
     <a href='index.php?option=com_a3000&task=showarticle&id=".$article->id."'>".$article->title."</a>
     </td></tr>n";         
  } 
  echo "</table></td></tr>";
  echo "</table>";
  search_mod_box();
}

function search_mod_box() {
global $module_name;
    echo "<br>";         
    echo "<div class=sectiontableheader>
    <form action='/index.php'>
    <table border=0><tr><td>
    <b>Search:</b> <input type=text name=term value=''>
    </td><td>
    <input type=submit value='search now…'>
    <input type='hidden' name='option' value='com_a3000'>
    <input type='hidden' name='task' value='showsearch'>
    </td></tr></table></form></div>";
}

switch ($task) {
   default:
      show_mod_categories();
   break;    

?>{/geshibot}

If everything went right you will now have Content blended directly into your main page.

Hope this helps and if you find an error in these instructions just let me know.

have fun,
chuck

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
heat
heat
heat
heat