Help modifying this module code

16 years 6 months ago #47341 by radio
Help modifying this module code was created by radio
Okey I want to get this module to display the author name and link back to their profile. Iv been playing with it but Im only learning php at the moment and cant get it to work. As far as I can tell its only a matter of changing the query to look for the correct field then outputting it and concatenating it correctly.

[code:1]defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

global $database, $mosConfig_offset;

$count = $params->get( 'count', 5 );
$section = $params->get( 'section', 'Mamblog' );
$now = date( "Y-m-d H:i:«»s", time()+$mosConfig_offset*60*60 );

$query = "SELECT id FROM #__sections WHERE title='$section'";
$database->setQuery($query);
$section_id = $database->LoadResult();

$query = "SELECT id FROM #__menu WHERE link='index.php?option=com_mamblog'";
$database->setQuery($query);
$Itemid = $database->LoadResult();

$query = "SELECT id, title"
. "\n FROM #__content"
. "\n WHERE sectionid='$section_id'"
. "\n AND state=1"
. "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now' )"
. "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now' )"
. "\n ORDER BY created DESC"
. "\n LIMIT $count"
;
$database->setQuery($query);
$rows = $database->loadObjectList();
echo $database->getErrorMsg();

foreach($rows as $row) {
echo '<a class="mainlevel" href="'.sefRelToAbs('index.php?option=com_mamblog&Itemid='.$Itemid.'&task=show&action=view&id='.$row->id).'">'.$row->title.'</a><br />';
}
?>[/code:1]

Interested in improving Joomla as a social networking platform? If yes join joomlaplazza.com

Please Log in to join the conversation.

16 years 6 months ago #47355 by nant

Please Log in to join the conversation.

16 years 6 months ago #47473 by radio
Replied by radio on topic Re:Help modifying this module code
No I dont think so. The author bot works with content items only right?. That code is from a front page module used to display the latest x number of new mamblog posts. But it only currently shows the post titles, Id like to get it to also display the author usernames and have this linked back to their profile just like what the author bot does for content items.

Interested in improving Joomla as a social networking platform? If yes join joomlaplazza.com

Please Log in to join the conversation.

16 years 6 months ago #47686 by radio
Replied by radio on topic Re:Help modifying this module code
Solved it in the end with no help from this forum. Anyway if you have the mamblog_latest module and you want it to display the author name and link to their cb profile change the query to this.

[code:1]$query = "SELECT c.id, c.title, u.username, c.created_by"
. "\n FROM #__content AS c"
. "\n LEFT JOIN #__users AS u ON u.id = c.created_by"
. "\n WHERE sectionid='$section_id'"
. "\n AND state=1"
. "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now' )"
. "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now' )"
. "\n ORDER BY created DESC"
. "\n LIMIT $count"
;
$database->setQuery($query);
$rows = $database->loadObjectList();
echo $database->getErrorMsg();

foreach($rows as $row) {
echo '<a class="mainlevel" href="'.sefRelToAbs('index.php?option=com_mamblog&Itemid='.$Itemid.'&task=show&action=view&id='.$row->id).'">'.$row->title.'</a><br />'.'<a href="'.sefRelToAbs('index.php?option=com_comprofiler&amp;task=userProfile&amp;user='.$row->created_by ).'">'.$row->username.'</a>';
}[/code:1]

Interested in improving Joomla as a social networking platform? If yes join joomlaplazza.com

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.161 seconds

Facebook Twitter LinkedIn