简体   繁体   中英

Joomla - order of pages in search results

The company I work for have inherited a Joomla site and I have no experience of Joomla, so I'm hoping that someone could let myself know if the following is possible.

When searching on the Joomla site, the client is expecting certain pages for certain search terms to appear at the top of the search results.

Is it possible to promote certain pages to the top of the search results depending on the search term?

Appreciate any support with this.

UPDATE

Testing locally I have updated the SQL query in /plugins/search/content.php to get close to the results that I am after.

SELECT
  a.title AS title,
  a.metadesc,
  a.metakey,
  a.created AS created,
  CONCAT(a.introtext, a.fulltext) AS text,
  CONCAT_WS( "/", u.title, b.title ) AS section,
  CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,
  CASE WHEN CHAR_LENGTH(b.alias) THEN CONCAT_WS(":", b.id, b.alias) ELSE b.id END as catslug, u.id AS sectionid, "2" AS browsernav 
FROM jos_content AS a 
  INNER JOIN jos_categories AS b ON b.id=a.catid 
  INNER JOIN jos_sections AS u ON u.id = a.sectionid 
WHERE
  ((a.title LIKE '%carbohydrate%' OR a.introtext LIKE '%carbohydrate%' OR a.fulltext LIKE '%carbohydrate%' OR a.metakey LIKE '%carbohydrate%' OR a.metadesc LIKE '%carbohydrate%'))
  AND a.state = 1 
  AND u.published = 1 
  AND b.published = 1 
  AND a.access <= 0 
  AND b.access <= 0 
  AND u.access <= 0 
  AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '2013-02-18 14:55:51' )
  AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '2013-02-18 14:55:51' ) 
GROUP BY a.id 
ORDER BY
  (NOT(a.title LIKE '%carbohydrate%'))
  , (NOT(a.introtext LIKE '%carbohydrate%'))
  , (NOT(a.fulltext LIKE '%carbohydrate%'))
  , (NOT(a.metakey LIKE '%carbohydrate%'))
  , (NOT(a.metadesc LIKE '%carbohydrate%'))

I would now like to have this as a custom plugin instead of over-writing any core plugins. I have followed the tutorial at http://docs.joomla.org/Creating_a_search_plugin but how do I set the site to use the custom plugin instead of the default search plugin?

Assuming you're using Joomla 2.5 (Although this might be the same for previous versions) you'll need to find the menu item within the 'Menu Manager' that displays the search results.

Within this menu item are some options under the 'Basic Options' tab. These include ordering search results by Newest First, Oldest First, Popularity, Alphabetical and by Category.

If the "fixed articles" are always the same, just override the search result template and add the articles in the template override.

Just copy all the files you find in

/components/com_search/views/search/tmpl

into

/templates/your_template/com_search/search

then edit default_results.php and place your fixed results there

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM