اول بگم من هیچی از PHP نمیدونم
کد زیر مال یه ماژوله که تبلیغات رو نشون میده اما اشکالش اینه که همه رو یا عمودی یا افقی نمایش میده
من میخوام تو حالت افقی وقتی سه تا از تبلیغاتها رو نشون داد بیاد خط بعد از اول خط سه تای بعدی رو نشون بده کد رو ویرایش کردم کجاش اشکال داره ؟
اونایی که قرمز کردم رو خودم ویراش کردم
البته بعضی کد ها تو کپی جا به جا شدن
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
$mosConfig_absolute_path = $GLOBALS['mosConfig_absolute_path'] = JPATH_SITE;
$database = &JFactory::getDBO();
$my=&JFactory::getUser();
$GLOBALS['database'] = &$database;
$GLOBALS['my']=&$my;
$acl =& JFactory::getACL();
$GLOBALS['acl'] =& $acl;
$Roochikcount = "3";
if( !function_exists( 'sefreltoabs')) {
function sefRelToAbs( $value ) {
//Need check!!!
// Replace all & with & as the router doesn't understand &
$url = str_replace('&', '&', $value);
if(substr(strtolower($url),0,9) != "index.php") return $url;
$uri = JURI::getInstance();
$prefix = $uri->toString(array('scheme', 'host', 'port'));
return $prefix.JRoute::_($url);
}
}
$selectstring = "SELECT id FROM #__menu WHERE link='index.php?option=com_advertisementboard'";
$database->setQuery($selectstring);
$ItemId_tmp = $database->loadResult();
$moduleclass_sfx = $params->get('moduleclass_sfx', '');
$count = intval($params->get('count',1));
$description = intval($params->get('description',1));
$g_words = $params->get('words','');
$showtitle = $params->get ('showtitle', '');
$showauthor = $params->get ('showauthor', '');
$showimage = $params->get ('showimage', 1);
$displaytype = $params->get ('displaytype', 0);
$imagesize = $params->get ('imagesize', '50');
$sortnewby = $params->get ('sortnewby', 0);
switch($sortnewby) {
case 0:
$sql_orderby_query = "date"; // Last Edited
break;
case 1:
$sql_orderby_query = "id"; // Last Added
break;
}
/*
$usergroups = $acl->get_group_parents($my->gid,'ARO','RECURSE');
if($usergroups) $usergroups=','.implode(',',$usergroups); else $usergroups='';
$usergroups = '-2,'.$my->gid.$usergroups;*/
$selectstring = "SELECT a.* FROM #__advertisementboard AS a LEFT JOIN #__advertisementboard_main_categories AS c ON c.id=a.catid ".
"WHERE a.published=1 AND c.published='1'".
"\nORDER BY ".$sql_orderby_query." DESC LIMIT 0,$count;";
$database->setQuery($selectstring);
$rows = $database->loadObjectList();
?>
<table border="1" cellpadding="3" cellspacing="3" class="moduletable" width="100%">
<?php
if($displaytype==1) { // Display Horizontal
?>
<tr valign="top">
<?php
}
?>
<?php foreach ($rows as $row) {
$comment = $row->comment;
$prevwords = count(explode(" ",$comment));
if(trim($g_words == "" )) $words = $prevwords;
else $words = intval($g_words);
$text = implode(" ", array_slice(explode(" ",$comment), 0, $words));
if (count(explode(" ",$text))<$prevwords){
$text .= "";
}
///http://localhost/~yura/joomla15/index.php?option=com_advertisementboard&task=listCategories&catid=217&id=5&Itemid=2&lang=en
$link1 = "index.php?option=com_advertisementboard&task=listCategories&catid=".$row->catid."&Itemid=".$ItemId_tmp."&id=".$row->id;
$selectlocation = "SELECT location from #__advertisementboard_images where fk_adv_id=".$row->id;
$database->setQuery($selectlocation);
$imageURL = $database->loadResult();
//for local images
if($imageURL != '' && substr($imageURL,0,4) != "http")
{
$imageURL = JURI::base() . $imageURL;
}
if($imageURL == ''){
$imageURL = "./components/com_medialibrary/images/no-img_eng.gif";
}
if($displaytype==1) { // Display Horizontal
if($showimage==1) {
?>
<td>
<a href="<?php echo sefRelToAbs( $link1 ); ?>" target="_self">
<img src="<?php echo $imageURL; ?>" hspace="15" vspace="2" border="0" height="<?php echo $imagesize; ?>" /></a>
</td>
<?php $Roochicount = $Roochikcount -1;
$imageURL = JURI::base() . $imageURL;
}
} //End Show Image If
?> <td valign="top">
<p><a class="readon" href="<?php echo sefRelToAbs( $link1 ); ?>" target="_self"></a></p></td>
<?php
if($Roochikcount == "0") {
?>
</tr>
<tr>
<?php
$Roochikcount = "3";
} ?>
<?php
} else {
//Display Vertical
?>
<tr valign="top">
<td>
<?php
if ($showtitle == "1") {
echo "<p><strong>".$row->title."</p></strong></a>";
} else {
echo " ";
}
if($showimage==1) {
?> <a href="<?php echo sefRelToAbs( $link1 ); ?>" target="_self">
<img src="<?php echo $imageURL; ?>" hspace="2" vspace="2" border="0" height="<?php echo $imagesize; ?>" /></a>
<?php } //End Show Image If?>
<?php
if ($showauthor == "1") {
echo "<br />Added by: ".$row->authors;
} else {
echo " ";
}
?>
<br />
<p><?php echo switchDescription ($text, $description); //for 1.6 ?></p>
<p><a class="readon" href="<?php echo sefRelToAbs( $link1 ); ?>" target="_self"></a></p>
</td>
</tr>
<tr> <td> </td>
</tr>
<?php
} //End Display If
}
?>
</tr>
<?php
if($displaytype==1) { // Display Horizontal
?>
</tr>
<?php
}
?>
</table>
<?php
function switchDescription ($text, $description) {
// for 1.6
switch ($description) {
case 1:
$text = substr ($text, 0, 100); $text .= '...';
break;
case 2:
$text = substr ($text, 0, 500); $text .= '...';
break;
case 3:
break;
case 4:
$text = '';
break;
}
return $text;
}
?>