Author Topic: Poor man's hack into Joomla Business Directory  (Read 3060 times)


  • Beginner
  • *
  • Posts: 37
Poor man's hack into Joomla Business Directory
« on: April 29, 2006, 18:22:14 pm »
Clearly, I am not a programmer, and this is one of the first things I have tried to accomplish in php.

I want to link back and forth between JBD and VM while the multi-vendor support in VM is still being developed (I hope!).  The manufacturer popups and categories in VM don't quite do what I need so I want to link to the JBD page for the manufacturer from my VM browse pages.  (I know this is not optimal and will require that the manufacturer/business will have to be entered in both tables the same way, etc. etc, but I am the only one administrating this site and it is relatively small so I don't mind.)  Manufacturer/business name is stored in a field called "title" in table jos__jdb.

I'm trying to write a function that will compare the strings stored in the "title" field in the _jbd table and the "mf_name" field in vm_manufacturer.  Then, from there I can retrieve the corresponding manufacturer/business id from the _jbd table and use it to link to that business in the JBD.

So far in shop.browse.php list product loop I am calling 2 custom functions "get_jbd_title" and "get_jbd_id" for each product id:
Code: [Select]
while ($db_browse->next_record()) {  /* while there are products */
    $manufacturer_id = $ps_product->get_manufacturer_id($db_browse->f("product_id"));
    $manufacturer_name = $ps_product->get_mf_name($db_browse->f("product_id"));
$jbdtitle = $ps_product->get_jbd_title($db_browse->f("product_id"));
$jbdid = $ps_product->get_jbd_id($db_browse->f("product_id"));

    $manufacturer_link = "";
    if( $manufacturer_id && !empty($manufacturer_name) ) {
        $link = "$mosConfig_live_site/index.php?option=com_jbd&Itemid=26&task=detail&navstart=0&mode=1&id=$jbdtitle&search=*";
            $text = '( '.$manufacturer_name.' )';
        $manufacturer_link .= "<a href=$link>".$text."</a>";

The get_jbd_title function looks like this so far: Keep in mind that I know there are matches, so I have not provided for a situation where there is no match.

Code: [Select]
function get_jbd_title($product_id) {

$db = new ps_DB;

$q = "SELECT title FROM #__jbd";  /* Construct the Query */

$db->query($q);  /* Execute the query constructed above */

$i = 0;

while ( $i < count( $q )) {  /* Loop through array and compare the strings */
            if ( strcmp($q[ $i ], $manufacturer_name ) != 0 ) {  /* If not a match -  move to next */
} else {
$jbdtitle = $q[$i];  /* When match is found, assign it */

$db->next_record();  /* Move to next product in the shop.browse while loop */
if (isset($jbdtitle)){
return $jbdtitle;  /* return the match */
else {
return false;

Can anyone guide me as to why this won't return a value from the "title" field of JBD that matches the $manufacturer_name retrieved from VM?

Thanks for reading.