• AdvSearch possible to search custom table in same DB?#

  • MikeMcNuke Reply #1, 8 months ago

    Reply
    Hi,

    I have a custom table with content and an according docid stored in it. Is it possible to search those fields in this custom table? Do I have to build an XPDO schema?? How does it work? Documentation of the joined resources did not bring any clues to me...

    Hope it is not a dump question *G*

    Greets
    MikeMcNuke


  • coroico Reply #2, 8 months ago

    Reply
    You need to provide the package name of your custom table. So you have to build an XPDO schema.

    Read the chapter Declaration syntaxes - Joined of the query hook document.
    This document is available from http://www.revo.wangba.fr/assets/files/cheatsheets/queryHook110_v1.0.pdf
    Look also the demo named Dvd


  • MikeMcNuke Reply #3, 8 months ago

    Reply
    Hi,

    many thanks for your tips. Will look into it!!!

    Bye


  • MikeMcNuke Reply #4, 8 months ago

    Reply
    Hi,

    model and schema is created. Works great.

    but now I still don't know what to do next...

    I should fill out the joinCriteria...but how should I fill it out so AdvSearch can tie a row of data from my table to a DocID ?? Is this even possible with it?



  • MikeMcNuke Reply #5, 8 months ago

    Reply
    Hi,

    model and schema is created. Works great.

    but now I still don't know what to do next...

    I should fill out the joinCriteria...but how should I fill it out so AdvSearch can tie a row of data from my table to a DocID ?? Is this even possible with it?

    Edit:
    Will try it with this snippet:
    <?php
    $joined = array(
    array(
    'package' => 'JHWproducts',
    'class' => 'jhwp',
    'packagePath' => '{core_path}components/JHWproducts/model/',
    'fields' => 'content',
    'withFields' => 'content',
    'joinCriteria' => 'jhwprodukte.docid = modResource.id'
    )
    );

    $qhDeclaration = array(
    'qhVersion' => '1.1',
    ‘joined’ => $joined,
    );

    $hook->setQueryHook($qhDeclaration);
    return true;

    Also tried this join:

    'joinCriteria' => 'jhwprodukte.docid = site_content.id'

    But no results...


  • coroico Reply #6, 8 months ago

    Reply
    Look at the quipQHook snippet used on the quip demo. You can download the queryHook snippet examples from the documentation page.

    Quip table is a joined table for the site_content table too.

    $joined = array(
        array(
            'package' => 'quip',
            'class' => 'quipComment',
            'packagePath' => '{core_path}components/quip/model/',
            'fields' => 'author , body , createdon ',   // displayed fields
            'withFields' => 'body',                     // search only in body field
    		'where' => array(							// where clause is primordial to avoid to search inside unapproved comments
                '((`quipComment`.`deleted` IS NULL) OR (`quipComment`.`deleted` = 0))',
                '((`quipComment`.`approved` IS NULL) OR (`quipComment`.`approved` = 1))'
    		),
            'joinCriteria' => 'quipComment.resource = modResource.id'
        )
    );



    EDIT:
    if jhwp is the class name, you should try :

    $joined = array(
    array(
    'package' => 'JHWproducts',
    'class' => 'jhwp',
    'packagePath' => '{core_path}components/JHWproducts/model/',
    'fields' => 'content',
    'withFields' => 'content',
    'joinCriteria' => 'jhwp.docid = modResource.id'
    )
    );


  • MikeMcNuke Reply #7, 8 months ago

    Reply
    Ah, ok thanks.