Fork me on GitHub

HTMLPAGES - Restrict Search Results To Titles Only  Bottom

  • I was looking at the htmlpages.php file that was copied to the /includes/search directory. But I could not find what I need to change to make PN only show htmlpages titles in the search results. At the moment, search results are showing any page that has the search word. Even if its just in the code of the page and not even displayed.

    Also... For some reason, if there is more than one result, its only showing 1 per page. How can I change this?

    My site is http://www.divinelighting.net ... Search for MWPC .... One of the htmlpages titles is MWPC. This is the only result I want to show.

    Below is the code...

    Code

    <?php
    /**
     * PostNuke Application Framework
     *
     * @copyright (c) 2004, PostNuke Development Team
     * @link http://www.postnuke.com
     * @version $Id: htmlpages.php,v 1.3 2006/03/17 14:53:31 markwest Exp $
     * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
     * @author Andrea Moro
     * @author Mark West
     * @author adam_baum
     * @author Kevin McCann
     * @package PostNuke_3rdParty_Modules
     * @subpackage htmlpages
     */


    $search_modules[] = array(
        'title' => 'HTMLPAGES',
        'func_search' => 'search_htmlpages',
        'func_opt' => 'search_htmlpages_opt'
    );

    function search_htmlpages_opt()
    {
        // load the language file
        pnModLangLoad('htmlpages', 'search');

        if (pnSecAuthAction(0, 'htmlpages::', '::', ACCESS_READ)) {
            $pnRender = new pnRender('htmlpages');
            return $pnRender->fetch('htmlpages_search_options.htm');
        }
    }

    function search_htmlpages() {

        list($q,
             $bool,
             $startnum,
             $total,
             $active_htmlpages) = pnVarCleanFromInput('q',
                                                 'bool',
                                                 'startnum',
                                                 'total',
                                                 'active_htmlpages');

        if (empty($active_htmlpages)) {
            return;
        }

        // load the language file
        pnModLangLoad('htmlpages', 'search');

        // load db tables
        pnModDBInfoLoad('htmlpages');

        // get database connection
        $dbconn = pnDBGetConn(true);
        $pntable = pnDBGetTables();

        if (!isset($startnum)) {
            $startnum = 1;
        }

        $w = search_split_query($q);
        $flag = false;
        $column = &$pntable['htmlpages_column'];
        $query = "SELECT $column[pid] as pid, $column[uid] as uid, $column[title] as title, $column[content] as content, $column[timest] as timest
                  FROM $pntable[htmlpages]
                  WHERE \n"
    ;
        foreach($w as $word) {
            if($flag) {
                switch($bool) {
                    case 'AND' :
                        $query .= ' AND ';
                        break;
                    case 'OR' :
                    default :
                        $query .= ' OR ';
                        break;
                }
            }
            $query .= '(';
            // faqs
            $query .= "$column[title] LIKE '$word' OR \n";
            $query .= "$column[content] LIKE '$word'\n";
            $query .= ')';
            $flag = true;
        }

        $query .= " ORDER BY $column[pid]";

        if (empty($total)) {
            $countres =& $dbconn->Execute($query);
            $total = $countres->PO_RecordCount();
            $countres->Close();
        }
        $result = $dbconn->SelectLimit($query, 1, $startnum-1);


        $items = array();
        if (!$result->EOF) {
            $pnRender = new pnRender('htmlpages');
            $pnRender->assign('total', $total);
            while(!$result->EOF) {
                $items[] = $result->GetRowAssoc(false);
                $result->MoveNext();
            }
            $pnRender->assign('items', $items);
            // Munge URL for template
            $urltemplate = "index.php?name=Search&amp;action=search&amp;active_htmlpages=1&amp;bool=$bool&amp;q=$q&amp;startnum=%%&amp;total=$total";
            $output = new pnHTML();
            $output->Pager($startnum, $total, $urltemplate, 1);
            $pnRender->assign('pager', $output->GetOutput());
            return $pnRender->fetch('htmlpages_search.htm');
        } else {
            return('<p>'._SEARCH_NO_HTMLPAGES.'</p>');
        }
    }

    ?>
  • Quote

    But I could not find what I need to change to make PN only show htmlpages titles in the search results.

    removing the line

    Code

    $query .= "$column[content] LIKE '$word'\n";

    should do the trick

    --
    regards from germany
    ..::[Zikula Application Framework]::.. ..::[SEO-Blog]::.. ..::[CMS Sicherheit]::..
  • larsneo

    Quote

    But I could not find what I need to change to make PN only show htmlpages titles in the search results.

    removing the line

    Code

    $query .= "$column[content] LIKE '$word'\n";

    should do the trick


    I tried that yesterday, Im a total rookie at understanding PHP code, but I read the whole file and took a wild guess. However, When I remove that line, and perform a search, I get an error.

    Fatal error: Call to a member function PO_RecordCount() on a non-object in /home/.cruise/mike1961/divinelighting.net/includes/search/htmlpages.php on line 94
  • 0 users

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