We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    I have an AdvSearch form that is searching multiple custom tables using the advsearch join syntax... problem is that several of these fields have duplication column names [such as 'name' and 'label']

    does anyone know how to write the join as a "SELECT columname AS uniquename'

    -thanks
    -sean
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 5811
      • 1,717 Posts
      As example, ( see http://www.revo.wangba.fr/custom-package-dvd-shop-2 ) if you have the following join:

      $joined = array(
      array(
      'package' => 'dvd',
      'class' => 'dvdCategories',
      'packagePath' => '{core_path}components/dvd/model/',
      'fields' => 'name , description',
      'withFields' => 'name , description',
      'joinCriteria' => 'dvdCategories.id = dvdProducts.category_id'
      )
      );

      Then the fields of the joined table will be renamed as class_fieldname

      for the above example: `dvdCategories`.`description` AS `dvdCategories_description`

      So you can use dvdCategories_description as field in your AdvSearch results

      In this example, the template of result is:

      <div class="advsea-result dvd">
          <div class="imgDvd"><img title="[[+name]]" src="assets/images/dvd/[[+image]]_thmb.jpg" alt="[[+name]]" /></div>
          <div class="titleDvd"><h3>[[+idx]]. [[+name]]</h3></div>
          <div>[[+extracts]]</div>
          <hr class="clear">
          <div><span class="flash">Code: </span>[[+code]]</div>
          <div><span class="flash">Category: </span>[[+dvdCategories_name]]</div>
          <div><span class="flash">Category description: </span>[[+dvdCategories_description]]</div>
          <div><span class="flash">Studio: </span>[[+studio]]</div>
          <div><span class="flash">Price: </span>[[+price]] $</div>
          <div><span class="flash">Year: </span>[[+production_year]]</div>
          <div><span class="flash">Weight: </span>[[+weight]]</div>    
          <div><span class="flash">In stock: </span>[[+in_stock]]</div>
      </div
      >
      Note the usage of dvdCategories_description field inside the result template.

      I agree with you, the documentation needs some improvements.