Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searching faqman tables not working #22

Open
BigBlockStudios opened this issue Oct 12, 2015 · 4 comments
Open

Searching faqman tables not working #22

BigBlockStudios opened this issue Oct 12, 2015 · 4 comments

Comments

@BigBlockStudios
Copy link

I have this set up to search faqman faqs...

&customPackages='faqManItem:question,answer:faqman:{core_path}components/faqman/model/:faqManItem.set = modResource.id'

now - I know there is no relation between faqman items and any resource, I'm hoping I can link them somehow in a posthook, HOWEVER in this case the faqManItem.set just happens to match several resources. So it should at least be displaying something...

thoughts?

@bwente
Copy link

bwente commented Nov 27, 2015

Are you trying to search faq's using simplesearch or trying to associate certain faq sets to a particular resource?

@BigBlockStudios
Copy link
Author

trying to search them with SS - though, simple search relies on an association with a resource in order for it to work.

@bwente
Copy link

bwente commented Nov 27, 2015

I created a posthook that searches the faqs.

<?php
$detailResource = 87;
$sortBy             = 'rank';
$sortDir            = 'ASC';

$packagePath = $modx->getOption('core_path').'components/faqman/model/';
$modx->addPackage('faqman', $packagePath);

$c = $modx->newQuery('faqManItem');
$c->where(array(
    'question:LIKE' => '%'.$search.'%',
    'OR:answer:LIKE' => '%'.$search.'%',
));

$c->sortby($sortBy, $sortDir);
$c->limit($limit,$offset);

$modx->setLogLevel(modX::LOG_LEVEL_DEBUG);

$faqs = $modx->getCollection('faqManItem',$c);

$results = array();
foreach ($faqs as $faq) {
$modx->log(modX::LOG_LEVEL_DEBUG,'ID = '.$faq->get('id'));
    $results[] = array(
        'pagetitle' => $faq->get('question'),
        'extract' => $faq->get('answer'),
        'link' => $modx->makeUrl($detailResource,'', array('faqs' => $faq->get('id'))),
        'id' => $faq->get('id'),
    );
}
$hook->addFacet('faq',$results);
return true;

@BigBlockStudios
Copy link
Author

Looks great [and thanks] but it still appears that we need to know what resource ID the faqs is in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants