awedge Posted April 29, 2010 Share Posted April 29, 2010 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] Quote Link to comment https://forums.phpfreaks.com/topic/200186-warning-complete-noob/ Share on other sites More sharing options...
andrewgauger Posted April 29, 2010 Share Posted April 29, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/200186-warning-complete-noob/#findComment-1050639 Share on other sites More sharing options...
awedge Posted April 30, 2010 Author Share Posted April 30, 2010 No, that didn't work. It just takes what I have and duplicates it over and over again. Quote Link to comment https://forums.phpfreaks.com/topic/200186-warning-complete-noob/#findComment-1050991 Share on other sites More sharing options...
andrewgauger Posted April 30, 2010 Share Posted April 30, 2010 sorry, I made a mistake: if ($si % 4 | $si == 0) $out .= "<tr class=\"extras_block\"> \n". should be if ($si % 4 | $si == 0) $out .= "<tr class=\"extras_block\"> \n"; Quote Link to comment https://forums.phpfreaks.com/topic/200186-warning-complete-noob/#findComment-1051095 Share on other sites More sharing options...
awedge Posted May 1, 2010 Author Share Posted May 1, 2010 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] Quote Link to comment https://forums.phpfreaks.com/topic/200186-warning-complete-noob/#findComment-1051516 Share on other sites More sharing options...
andrewgauger Posted May 2, 2010 Share Posted May 2, 2010 Is this in a live environment where I can access the page? If so please either post the url or PM me it, I can't continue without seeing how it is being sent to the browser. I've never used Joomla. Quote Link to comment https://forums.phpfreaks.com/topic/200186-warning-complete-noob/#findComment-1051732 Share on other sites More sharing options...
awedge Posted May 3, 2010 Author Share Posted May 3, 2010 No it is not live. I have it on my mac (localhost). I will see if I can locate the html and post that for you. Quote Link to comment https://forums.phpfreaks.com/topic/200186-warning-complete-noob/#findComment-1052343 Share on other sites More sharing options...
awedge Posted May 3, 2010 Author Share Posted May 3, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/200186-warning-complete-noob/#findComment-1052354 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.