Fork me on GitHub

i need that module subjects works also in seach of zikula  Bottom

  • hello, i need that module subjects works also in seach of zikula...the problem is that the words are not looked for in the module subjects and i would like to get that module search look for also into this module.

    where can i to include this?.....and if it is posible how to do it?



    edited by: mercromina, datetimebrief

    --
    www.ahorradores.net
  • How a module is searched is up to the module author and is not dictated by the framework. If you want to get an idea how search is done, look at the search.php file in any module. Is there a specific module you want searched or all of them. If it is a specific module, then you could talk to the module author or try to make some changes yourself.
  • yes and no. of course it is necesary to create files, etc...but i dont know how to do it...and the creator of subjects module is missing.
    i have been investigating and it seems that in zikula to get the search works in other modules, it is necesary to create a pnsearchapi.php file that it is similar to the pnseachapi.php to others modules...for example EZComments... it is necesary to create also a a folder "pntemplates" where create a file like this ezcomments_search_form.htm
    In these files i have changed EZComments by subjects...and the selector appears in the search form for subjects...it seems that zikula look for automatically into the tables of the module...but dont work... the error code is :

    Code

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE '%pañales%' OR LIKE '%pañales%')) AND != ''' at line 1
    select nuke_subjects.subid as "subid",nuke_subjects.catid as "catid",nuke_subjects.subname as "subname",nuke_subjects.subtext as "subtext",nuke_subjects.subimage as "subimage",nuke_subjects.subactive as "subactive",nuke_subjects.suborder as "suborder",nuke_subjects.subcounter as "subcounter",nuke_subjects.keywords as "keywords",nuke_subjects.sublanguage as "sublanguage" from nuke_subjects as tbl where ( ( like '%pañales%' or like '%pañales%')) and != ''


    my new pnsearchapi.php by subjects module is this(i only have changed EZComments by subjects):

    Code

    * Search plugin info
     **/
    function subjects_searchapi_info()
    {
        return array(   
            'title'     => 'subjects',
            'functions' => array(
                                    'subjects' => 'search'
                                ));
    }

    /**
     * search_subjects_options()
     *
     * This function will be called to display the search box.
     *
     * @return output the search field
     **/

    function subjects_searchapi_options($args)
    {
        if (SecurityUtil::checkPermission( 'subjects::', '::', ACCESS_READ)) {
            // Create output object - this object will store all of our output so that
            // we can return it easily when required
            $pnRender = pnRender::getInstance('subjects');
            $pnRender->assign('active',(isset($args['active'])&&isset($args['active']['subjects']))||(!isset($args['active'])));
            return $pnRender->fetch('subjects_search_form.htm');
        }
        return '';
    }

    /**
     * search_subjects()
     *
     * do the actual search and display the results
     *
     * @return output the search results
     **/

    function subjects_searchapi_search($args)
    {
        if (!SecurityUtil::checkPermission( 'subjects::', '::', ACCESS_READ)) {
            return true;
        }

        if (strlen($args['q']) < 3 || strlen($args['q']) > 30) {
            return LogUtil::registerStatus(pnML('_subjects_SEARCHLENGTHHINT', array('minlen' => $minlen, 'maxlen' => $maxlen)));
        }

        pnModDBInfoLoad('Search');
        $pntable        = pnDBGetTables();
        // subjects tables
        $subjectstable  = $pntable['subjects'];
        $subjectscolumn = $pntable['subjects_column'];
        // our own tables
        $searchTable    = $pntable['search_result'];
        $searchColumn   = $pntable['search_result_column'];
        // where
        $where = search_construct_where($args,
                                        array($subjectscolumn['subject'],
                                              $subjectscolumn['comment']));
        $where.=" AND ".$subjectscolumn['url']." != ''";
        $sessionId = session_id();

        $insertSql =
            "INSERT INTO $searchTable
              ($searchColumn[title],
               $searchColumn[text],
               $searchColumn[extra],
               $searchColumn[module],
               $searchColumn[created],
               $searchColumn[session])
            VALUES
            "
    ;

        $comments = DBUtil::selectObjectArray('subjects', $where);

        foreach ($comments as $comment)
        {
              $sql = $insertSql . '('
                     . '\'' . DataUtil::formatForStore($comment['subject']) . '\', '
                     . '\'' . DataUtil::formatForStore($comment['comment']) . '\', '
                     . '\'' . DataUtil::formatForStore($comment['url']) . '\', '
                     . '\'' . 'subjects' . '\', '
                     . '\'' . DataUtil::formatForStore($comment['date']) . '\', '
                     . '\'' . DataUtil::formatForStore($sessionId) . '\')';
              $insertResult = DBUtil::executeSQL($sql);
              if (!$insertResult) {
                  return LogUtil::registerError (_GETFAILED);
              }
        }
        return true;
    }

    /**
     * Do last minute access checking and assign URL to items
     *
     * Access checking is ignored since access check has
     * already been done. But we do add a URL to the found comment
     */

    function subjects_searchapi_search_check(&$args)
    {
        $datarow = &$args['datarow'];
        $url = $datarow['extra'];
        $datarow['url'] = $url;
        return true;
    }


    --
    www.ahorradores.net
  • ok i have seen that it is necesary to change some columns...if i get i will tell to us

    --
    www.ahorradores.net
  • i still have problems, this is the pnsearchapi.php that i have created for subjects:

    Code

    function subjects_searchapi_info()
    {
        return array(    
               'title'     => 'subjects',
            'functions' => array(
                                    'subjects' => 'search'
                                 ));
    }

    /**
     * search_subjects_options()
     *
     * This function will be called to display the search box.
     *
     * @return output the search field
     **/

    function subjects_searchapi_options($args)
    {
        if (SecurityUtil::checkPermission( 'subjects::page', '::', ACCESS_READ)) {
            // Create output object - this object will store all of our output so that
            // we can return it easily when required
            $pnRender = pnRender::getInstance('subjects');
            $pnRender->assign('active',(isset($args['active'])&&isset($args['active']['subjects']))||(!isset($args['active'])));
            return $pnRender->fetch('subjects_search_form.htm');
        }
        return '';
    }

    /**
     * search_subjects()
     *
     * do the actual search and display the results
     *
     * @return output the search results
     **/

    function subjects_searchapi_search($args)
    {
        if (!SecurityUtil::checkPermission( 'subjects::page', '::', ACCESS_READ)) {
            return true;
        }

        pnModDBInfoLoad('Search');
        $pntable         = pnDBGetTables();
        // subjects tables
        $subjectstable     = $pntable['subpages'];
        $subjectscolumn = $pntable['subpages_column'];
        // our own tables
        $searchTable     = $pntable['search_result'];
        $searchColumn     = $pntable['search_result_column'];
        // where
        $where = search_construct_where($args,
                                        array($subjectscolumn['pagetitle'],
                                              $subjectscolumn['pagetext'],
                                              $subjectscolumn['pagecontent']));
       
        $sessionId = session_id();

        $insertSql =
            "INSERT INTO $searchTable
              ($searchColumn[title],
               $searchColumn[text],
               $searchColumn[extra],
               $searchColumn[module],
               $searchColumn[created],
               $searchColumn[session])
            VALUES
            "
    ;

        $subjects = DBUtil::selectObjectArray('subpages', $where);
           
        foreach ($subjects as $subject)
        {
              $sql = $insertSql . '('
                     . '\'' . DataUtil::formatForStore($subject['pagetitle']) . '\', '
                     . '\'' . DataUtil::formatForStore($subject['pagetext']) . '\', '
                     . '\'' . DataUtil::formatForStore($subject['pageid']) . '\', '
                     . '\'' . DataUtil::formatForStore($subject['subid']) . '\', '
                     . '\'' . 'subjects' . '\', '
                     . '\'' . DataUtil::formatForStore($subject['date']) . '\', '
                     . '\'' . DataUtil::formatForStore($sessionId) . '\')';
              $insertResult = DBUtil::executeSQL($sql);
              if (!$insertResult) {
                  return LogUtil::registerError (_GETFAILED);
              }
        }
        return true;
    }

    /**
     * Do last minute access checking and assign URL to items
     *
     * Access checking is ignored since access check has
     * already been done. But we do add a URL to the found subject
     */

    function subjects_searchapi_search_check(&$args)
    {
        $datarow = &$args['datarow'];
        $url = $datarow['extra'];
        $datarow['url'] = $url;
        return true;
    }


    but still dont work: this is the error:

    Code

    Unknown column 'nuke_subpages.pageid' in 'field list'
    select nuke_subpages.pageid as "pageid",nuke_subpages.subid as "subid",nuke_subpages.parentpageid as "parentpageid",nuke_subpages.pagetitle as "pagetitle",nuke_subpages.pagetext as "pagetext",nuke_subpages.pagecontent as "pagecontent",nuke_subpages.pagefile as "pagefile",nuke_subpages.pageimage as "pageimage",nuke_subpages.pageauthor as "pageauthor",nuke_subpages.pageauthoremail as "pageauthoremail",nuke_subpages.pageauthorurl as "pageauthorurl",nuke_subpages.pageactive as "pageactive",nuke_subpages.pageorder as "pageorder",nuke_subpages.pagedatetime as "pagedatetime",nuke_subpages.pagecounter as "pagecounter",nuke_subpages.reviewactive as "reviewactive",nuke_subpages.reviewscount as "reviewscount",nuke_subpages.reviewsscore as "reviewsscore",nuke_subpages.keywords as "keywords",nuke_subpages.username as "username" from nuke_subpages as tbl where ( (nuke_subpages.pagetitle like '%pañales%' or nuke_subpages.pagetext like '%pañales%' or nuke_subpages.pagecontent like '%pañales%'))


    and the column "pageid" exist... ¿?¿?

    some idea by the reason please?



    edited by: mercromina, datetimebrief

    --
    www.ahorradores.net

This list is based on users active over the last 60 minutes.