0

Hello I would like to build a module that display articles of a category (Unfortunately I can't use the native module since these category has other prefix). Something like the native joomla module.

I know how to connect to the table

$db =& JFactory::getDBO();  

the query works :

$query = "SELECT title FROM rsc_content WHERE catid=68";


Something that might come after (?):

$db->setQuery($query);

Then I do not know... Any idea?

(i have a code that works to retrieve a single article using joomla code :

<?php $db =& JFactory::getDBO(); 
$query = "SELECT introtext FROM rsc_content WHERE id=49 ";
$db->setQuery($query);
$text= $db->loadResult();
echo $text;
?>

1 Answer 1

0

First get from database what you need:

<?php 
$db =& JFactory::getDBO(); 
$db->setQuery("SELECT title FROM rsc_content WHERE catid=68");
$list= $db->loadResultArray();

Then traverse the result list and display contents:

foreach($list as $title) {
  echo $title . "<br />";
}
4
  • Thanks WooDzu ! And how could I get them with a clickable link? (I ll give a try to see how it looks like)
    – JinSnow
    Jul 20, 2012 at 16:08
  • It depends if you're using SEF or not
    – WooDzu
    Jul 20, 2012 at 16:59
  • Thanks for your reply! Ok i guess i should manage to make it in SEF. Thanks I did not know about that link... Well your code give me a Parse error: syntax error, unexpected T_ECHO in are you sure about your <br />?
    – JinSnow
    Jul 20, 2012 at 17:11
  • I'm using the SEF URL. Here is the code, something wrong somewhere ... ` <?php $db =& JFactory::getDBO(); $db->setQuery("SELECT title FROM rsc_content WHERE catid=68"); $list= $db->loadResultArray(); foreach($list as $title) { echo $title . "<br />"; } `
    – JinSnow
    Jul 20, 2012 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.