I am having to hack a Joomla module....I am doing ok but in this one component i do not undertand what the following code. i am not sure whta the a. b. c. 's are ($pagingParams['posts_sortby']) { case "subject": $order = "a.subject ASC, a.time DESC"; break; case "category": $order = "b.id ASC, a.time DESC"; break; case "hits": $order = "c.hits DESC, break;
That's not all the code. Anyway, it's just a snippet that builds a query. If Sort By = Subject $order is this, if Sort By = Category then $order = that... etc.
Well, in response to his actual question, the a, b, c are different tables. If you look at the rest of the code you'll probably see something like this: SELECT * FROM table1 AS a, table2 AS b, table3 AS c Code (markup): This method is often used when you work with table prefixes. Your code is the part that orders the results.
No, they are just aliases. In your query should be something like. SELECT * FROM original_table_name1 AS a, original_table_name2 AS b, original_table_name3 AS c Code (markup): This is used for exaple if you want to select a lot of different fields from different tables, or if you have table pefixes, to make the query shorter. So instead of SELECT yourprefix_table1.name, yourprefix_table2.id, yourprefix_table3.something FROM yourprefix_table1, yourprefix_table2, yourprefix_table3 Code (markup): You can do: SELECT a.name, b.id, c.something FROM yourprefix_table1 AS a, yourprefix_table2 AS b, yourprefix_table3 AS c Code (markup): Might be a bad example, but it's much more simple for long queries.
Here some more info http://dev.mysql.com/doc/refman/5.0/en/select.html (Just scroll a little bit down)
i am in the process of learning but sadly i dont have many people to ask i am hacking a joomla module and tyring to undertand. if i may pic you rmind just a bit more i am trying to figure out why he would use $content .= so many times instead just putting what is in quotes. // Output the document name $content .= $doc->getData('dmname'); // If we are showing the counter or the category, do it if ($show_counter) { $content .= " (".$doc->getData('dmcounter').")"; } if ($show_category) { $content .= "<br />(".$row->cat_title.")"; } // Add the end link and break $content .= "</a>"; // List output if ( $show_list == 1 ) { $content .= "</li>"; } else { $content .= "<br />"; } } I am also trying to understand what & means in this line $linkText = "index.php?option=com_docman&Itemid=$menuid&task=doc_download again lots of thanks
The dot operator infront of the equal sign adds more content to the current variable, which is $content in your case. http://us2.php.net/manual/en/language.operators.string.php And the & is HTML for the & symbol. And please use wrappers when posting PHP code. :) PHP:
Hey thanks again, It like i know all of this stuff but i have never seen it actually used so i am piecing the stuff together..... like i really cannot ever imagine where I would use a loop even though i can recreate every tutorial by memory..... i didn't know about the tags. i will use them from now on
This code is shorter but illustrates the same point. This is a module for Joomla with Community Builder <?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); $revshare_ad_format = $params->get('revshare_ad_format'); $revshare_format = explode("-", $revshare_ad_format); $revshare_ad_width = explode("x", $revshare_format[0]); $revshare_ad_height = explode("_", $revshare_ad_width[1]); $ip_safe = 1; if ($_SERVER["REMOTE_ADDR"] == $params->get('revshare_ip_block1')) $ip_safe = 0; if ($_SERVER["REMOTE_ADDR"] == $params->get('revshare_ip_block2')) $ip_safe = 0; if ($_SERVER["REMOTE_ADDR"] == $params->get('revshare_ip_block3')) $ip_safe = 0; if ($_SERVER["REMOTE_ADDR"] == $params->get('revshare_ip_block4')) $ip_safe = 0; if ($_SERVER["REMOTE_ADDR"] == $params->get('revshare_ip_block5')) $ip_safe = 0; // Add another if statement here with another IP address if // you wish to block it as well. You can change this to use // an array if you have a bigger list. // //$ip_safe = 1; // debugging. Uncomment if you want to see the ads if ($ip_safe) { global $database, $my; $uid = $my->id; // current user id $cid = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); // content piece id $ads = $params->get('revshare_ad_client'); // site default adsense id $chl = $params->get('revshare_ad_channel'); //default channel $altAd = false; if ($cid > 0) { // first check get author and adsense info $query = "SELECT a.created_by, b.cb_adsenseid, b.cb_adsensechannelid, a.hits" . "FROM #__content AS a INNER JOIN #__comprofiler AS b " . "ON a.created_by = b.user_id " . "WHERE a.id = " . $cid; //echo $query; $database->setQuery( $query ); $info = $database->loadRow(); $aid = $info[0]; // author id $asid = $info[1]; // google adsense id $ascid = $info[2]; // google adsense channel id $hits = $info[3]; // # of hits //echo ($uid==$aid); if ($aid != $uid) { // only display ad if visitor is not author, prevent TOS violation $modder = intval($params->get('revshare_percent')); if ($hits%$modder==0) { // only do 50% of time $newAds = $asid; if($newAds!="") { $ads = $newAds; $chl = $ascid; $altAd = true; } } } } echo '<div style="float:' . $params->get('revshare_ad_align') . ';width:' . $revshare_ad_width[0] . 'px;height:' . $revshare_ad_height[0] . 'px;margin:auto;padding:auto;">'; if ($altAd) echo "<!-- author's ads -->"; echo "<script language=\"javascript\">\r\n" . "<!--\r\n" . "google_ad_client = \"" . $ads . "\";\r\n" . "google_alternate_ad_url = \"" . $params->get('revshare_alternate_ad_url') . "\"; \r\n" . "google_alternate_color = \"" . $params->get('revshare_alternate_color') . "\"; \r\n" . "google_ad_width = " . $revshare_ad_width[0] . "; \r\n" . "google_ad_height = " . $revshare_ad_height[0] . "; \r\n" . "google_ad_format = \"" . $revshare_format[0] . "\"; \r\n" . "google_ad_type = \"" . $params->get('revshare_ad_type') . "\"; \r\n" . "google_ad_channel = \"" . $chl . "\"; \r\n" . ( $params->get('revshare_ad_in_frame') ? "google_page_url = document.location; \r\n" : "") . "google_color_border = [\"" . $params->get('revshare_color_border1') . "\",\"" . $params->get('revshare_color_border2') . "\",\"" . $params->get('revshare_color_border3') . "\",\"" . $params->get('revshare_color_border4') . "\"]; \r\n" . "google_color_bg = [\"" . $params->get('revshare_color_bg1') . "\",\"" . $params->get('revshare_color_bg2') . "\",\"" . $params->get('revshare_color_bg3') . "\",\"" . $params->get('revshare_color_bg4') . "\"]; \r\n" . "google_color_link = [\"" . $params->get('revshare_color_link1') . "\",\"" . $params->get('revshare_color_link2') . "\",\"" . $params->get('revshare_color_link3') . "\",\"" . $params->get('revshare_color_link4') . "\"]; \r\n" . "google_color_url = [\"" . $params->get('revshare_color_url1') . "\",\"" . $params->get('revshare_color_url2') . "\",\"" . $params->get('revshare_color_url3') . "\",\"" . $params->get('revshare_color_url4') . "\"]; \r\n" . "google_color_text = [\"" . $params->get('revshare_color_text1') . "\",\"" . $params->get('revshare_color_text2') . "\",\"" . $params->get('revshare_color_text3') . "\",\"" . $params->get('revshare_color_text4') . "\"]; \r\n" . "//--> \r\n" . "</script>\r\n" . "<script language=\"javascript\" src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\"></script>\r\n"; echo '</div>'; } else { // This is what visitors from the blocked IP addresses will see (specified above). // This shows a table with the dimensions of the ad. Change as needed. echo '<div style="float: none; margin: 0px 0px 0px 0px;">' . $params->get('ip_block_alt_code') . '</div>'; } ?> PHP: I am not sure where he is defining $query = "SELECT a.created_by, b.cb_adsenseid, b.cb_adsensechannelid, a.hits" . "FROM #__content AS a INNER JOIN #__comprofiler AS b " PHP: