Jump to content

Recommended Posts

OK, even noob is an understatement. php might as well be written in chinese when I look at it. Here is my problem. I have a joomla extension and need to make what is probably a simple tweek but I have no clue what to do.

 

The extension allows my site visitors to schedule appointments and services online. In addition to the services there is the ability to add extras that might be needed and there in lies my problem.

 

when I add the extra services in the back end they just align vertical straight down the page. if I need to place 20 of them this just waists a ton of space. See attached image:

 

 

From what I can gather this is not controlled by the css file and therefore takes me out of the loop.

 

I need to add about 20 "extras" so 4 columns of 5 rows each would be great. From what I can see this is the code that controls it. I even think I can see where it is but have no idea how to change it.

// ************************************
	// get extras for the resource
	// ************************************
	$out = "<table>\n";

	// get seat types
	$database = &JFactory::getDBO(); 
	$sql = 'SELECT * FROM #__sv_apptpro_extras WHERE published=1 AND (resource_scope = "" OR resource_scope LIKE \'%|'.$resource.'|%\' ';
/*		Not implemented, too complex due to simulatuous asynchronous changing of resources and services, may a future feature
	if($service != ""){
		$sql .= ' OR service_scope LIKE \'%|'.$service.'|%\'';
	}
*/		$sql .= ") ORDER BY ordering";
	$database->setQuery($sql);
	$extras_rows = $database -> loadObjectList();
	if ($database -> getErrorNum()) {
		echo "DB Err: ". $database -> stderr();
		return false;
	}

	$si = 0; 
	if(count($extras_rows)>0){  
		$out .= "<tr class=\"extras_block\">\n".
		  "<td class=\"sv_apptpro_request_label\">".JText::_('RS1_INPUT_SCRN_EXTRAS_LABEL').":</td>\n".
		  "<td colspan=\"3\" valign=\"top\"></td>\n".
		"</tr>\n";
	}
	foreach($extras_rows as $extras_row){
		$out .= "<tr class=\"extras_block\"> \n".
			"<td class=\"sv_apptpro_request_label\">".JText::_($extras_row->extras_label).":</td>\n".
		  	"<td colspan=\"2\" valign=\"top\">\n".
		  	"<select name=\"extra_".$si."\" id=\"extra_".$si."\" onChange=\"calcTotal();\" class=\"sv_apptpro_request_dropdown".($mobile=="Yes"?"_mobile":"")."\" ". 
			"title='".JText::_($extras_row->extras_tooltip)."'  />\n";
			for($i=0; $i<=$extras_row->max_quantity; $i++){ 
				$out .=	"<option value=".$i.($i==$extras_row->default_quantity?" selected":"").">".$i."</option>\n";	        
			}
		   $out .= "</select>\n". 
			" ".JText::_($extras_row->extras_help)." \n".
			"<input type=\"hidden\" name=\"extras_cost_".$si."\" id=\"extras_cost_".$si."\" value=\"".$extras_row->extras_cost."\"/>\n".  
			"<input type=\"hidden\" name=\"extras_cost_unit_".$si."\" id=\"extras_cost_unit_".$si."\" value=\"".$extras_row->cost_unit."\"/>\n".  
			"<input type=\"hidden\" name=\"extras_id_".$si."\" id=\"extras_id_".$si."\" value=\"".$extras_row->id."\"/>\n".  
		  " </td>\n".
		"</tr>\n";
		$si += 1; 
	} 

	if($out == "<table>\n"){
		$out="";
	} else {
		$out .= "</table>\n";
	}
	$out .= "<input type=\"hidden\" name=\"extras_count\" id=\"extras_count\" value=\"".count($extras_rows)."\">\n";
	echo $out;				
	exit;

} else if(JRequest::getVar('adminserv') == "yes"){

 

Anyone dare try to help me out on this one?

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/200186-warning-complete-noob/
Share on other sites

I get this done by tracking an incrementing variable and newline on modulus(%)

 

You are already incrementing the variable $si and I will use this variable to determine if we should be printing the <tr> and </tr> tags.

 

// ************************************
	// get extras for the resource
	// ************************************
	$out = "<table>\n";

	// get seat types
	$database = &JFactory::getDBO(); 
	$sql = 'SELECT * FROM #__sv_apptpro_extras WHERE published=1 AND (resource_scope = "" OR resource_scope LIKE \'%|'.$resource.'|%\' ';
/*		Not implemented, too complex due to simulatuous asynchronous changing of resources and services, may a future feature
	if($service != ""){
		$sql .= ' OR service_scope LIKE \'%|'.$service.'|%\'';
	}
*/		$sql .= ") ORDER BY ordering";
	$database->setQuery($sql);
	$extras_rows = $database -> loadObjectList();
	if ($database -> getErrorNum()) {
		echo "DB Err: ". $database -> stderr();
		return false;
	}

	$si = 0; 
	if(count($extras_rows)>0){  
		$out .= "<tr class=\"extras_block\">\n".
		  "<td class=\"sv_apptpro_request_label\">".JText::_('RS1_INPUT_SCRN_EXTRAS_LABEL').":</td>\n".
		  "<td colspan=\"3\" valign=\"top\"></td>\n".
		"</tr>\n";
	}
	foreach($extras_rows as $extras_row){
if ($si % 4 | $si == 0) 
		$out .= "<tr class=\"extras_block\"> \n".

                        $out .="<td class=\"sv_apptpro_request_label\">".JText::_($extras_row->extras_label).":</td>\n".
		  	"<td colspan=\"2\" valign=\"top\">\n".
		  	"<select name=\"extra_".$si."\" id=\"extra_".$si."\" onChange=\"calcTotal();\" class=\"sv_apptpro_request_dropdown".($mobile=="Yes"?"_mobile":"")."\" ". 
			"title='".JText::_($extras_row->extras_tooltip)."'  />\n";
			for($i=0; $i<=$extras_row->max_quantity; $i++){ 
				$out .=	"<option value=".$i.($i==$extras_row->default_quantity?" selected":"").">".$i."</option>\n";	        
			}
		   $out .= "</select>\n". 
			" ".JText::_($extras_row->extras_help)." \n".
			"<input type=\"hidden\" name=\"extras_cost_".$si."\" id=\"extras_cost_".$si."\" value=\"".$extras_row->extras_cost."\"/>\n".  
			"<input type=\"hidden\" name=\"extras_cost_unit_".$si."\" id=\"extras_cost_unit_".$si."\" value=\"".$extras_row->cost_unit."\"/>\n".  
			"<input type=\"hidden\" name=\"extras_id_".$si."\" id=\"extras_id_".$si."\" value=\"".$extras_row->id."\"/>\n".  
		  " </td>\n";
		$si += 1; 
if($si % 4)
		$out.="</tr>\n";

	} 

	if($out == "<table>\n"){
		$out="";
	} else {
if (substr($out, -5) != "</tr>")
$out.="</tr>";
		$out .= "</table>\n";
	}
	$out .= "<input type=\"hidden\" name=\"extras_count\" id=\"extras_count\" value=\"".count($extras_rows)."\">\n";
	echo $out;				
	exit;

} else if(JRequest::getVar('adminserv') == "yes"){

 

I also put in code to verify that the last </tr> got inserted.  Savvy?

Man I wish I knew this stuff, for what it is worth i have been trying to figure this out as well with the help of w3 schools and trying to learn a little php but it is still way over my head.

 

Anyways, I applied your fix, looked at the site and thought you had it. One of the extras did in fact move to the right in a new column. However everyone I added in the back end of Joomla after that, still just continued straight down the page. I have attached another image so you can see.

 

BTW, have i said thank you yet?????

 

 

[attachment deleted by admin]

Ok, here is the HTML that is output for the page. Looks like the last <tr> in this block.

 

<tr id="services" style="visibility:hidden; display:none">
      <td class="sv_apptpro_request_label">Services:</td>
    <td colspan="3"><div id="services_div"> </div></td>
    </tr>
    <tr id="resource_udfs" style="visibility:hidden; display:none"><td></td><td colspan="3"><div id="resource_udfs_div"></div></td></tr>
    <tr id="resource_seat_types" style="visibility:hidden; display:none"><td colspan="4"><div id="resource_seat_types_div"></div></td></tr>
    <tr id="resource_extras" style="visibility:hidden; display:none"><td colspan="4"><div id="resource_extras_div"></div></td></tr>

 

I tried changing the "display" to inline and it had no effect in the css file.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.