За последние 24 часа нас посетили 58908 программистов и 1771 робот. Сейчас ищут 835 программистов ...

url search - controller joomla

Тема в разделе "PHP для новичков", создана пользователем Espey, 10 мар 2017.

  1. Espey

    Espey Зэк
    [ БАН ]

    С нами с:
    25 ноя 2016
    Сообщения:
    129
    Симпатии:
    4
    Добрый день люди добрые. У меня проблема с Joomla.

    В общем я настраиваю url в компоненте com_search. Установил Arito JoomSef и включил опцию JoomSEF basic rewriting для поиска.

    Ссылки поиска стали выглядеть так: http://сайт/трансляция-поискового-запроса-на-английский-язык.html

    В общем я облазил весь компонент Arito JoomSef с желанием, что то изменить и не чего в нем не нашел.

    Пришел к выводу, что нужно искать в другом месте. Нашел в controller.php com_search. Только вот я не пойму, как из url адреса com_search убрать трансляцию поискового запроса?

    Вот сам файл controller.php com_search:

    PHP:
    1. <?php
    2. /**
    3. * @package     Joomla.Site
    4. * @subpackage  com_search
    5. *
    6. * @copyright   Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
    7. * @license     GNU General Public License version 2 or later; see LICENSE.txt
    8. */
    9.  
    10. defined('_JEXEC') or die;
    11.  
    12. /**
    13. * Search Component Controller
    14. *
    15. * @since  1.5
    16. */
    17. class SearchController extends JControllerLegacy
    18. {
    19.     /**
    20.      * Method to display a view.
    21.      *
    22.      * @param   bool  $cachable   If true, the view output will be cached
    23.      * @param   bool  $urlparams  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
    24.      *
    25.      * @return  JControllerLegacy This object to support chaining.
    26.      *
    27.      * @since   1.5
    28.      */
    29.     public function display($cachable = false, $urlparams = false)
    30.     {
    31.         // Force it to be the search view
    32.         $this->input->set('view', 'search');
    33.  
    34.         return parent::display($cachable, $urlparams);
    35.     }
    36.  
    37.     /**
    38.      * Search
    39.      *
    40.      * @return void
    41.      *
    42.      * @throws Exception
    43.      */
    44.     public function search()
    45.     {
    46.         // Slashes cause errors, <> get stripped anyway later on. # causes problems.
    47.         $badchars = array('#', '>', '<', '\\');
    48.         $searchword = trim(str_replace($badchars, '', $this->input->getString('searchword', null, 'post')));
    49.  
    50.         // If searchword enclosed in double quotes, strip quotes and do exact match
    51.         if (substr($searchword, 0, 1) == '"' && substr($searchword, -1) == '"')
    52.         {
    53.             $post['searchword'] = substr($searchword, 1, -1);
    54.             $this->input->set('searchphrase', 'exact');
    55.         }
    56.         else
    57.         {
    58.             $post['searchword'] = $searchword;
    59.         }
    60.  
    61.         $post['ordering']     = $this->input->getWord('ordering', null, 'post');
    62.         $post['searchphrase'] = $this->input->getWord('searchphrase', 'all', 'post');
    63.         $post['limit']        = $this->input->getUInt('limit', null, 'post');
    64.  
    65.         if ($post['limit'] === null)
    66.         {
    67.             unset($post['limit']);
    68.         }
    69.  
    70.         $areas = $this->input->post->get('areas', null, 'array');
    71.  
    72.         if ($areas)
    73.         {
    74.             foreach ($areas as $area)
    75.             {
    76.                 $post['areas'][] = JFilterInput::getInstance()->clean($area, 'cmd');
    77.             }
    78.         }
    79.  
    80.         // The Itemid from the request, we will use this if it's a search page or if there is no search page available
    81.         $post['Itemid'] = $this->input->getInt('Itemid');
    82.  
    83.         // Set Itemid id for links from menu
    84.         $app  = JFactory::getApplication();
    85.         $menu = $app->getMenu();
    86.         $item = $menu->getItem($post['Itemid']);
    87.  
    88.         // The requested Item is not a search page so we need to find one
    89.         if ($item->component != 'com_search' || $item->query['view'] != 'search')
    90.         {
    91.             // Get item based on component, not link. link is not reliable.
    92.             $item = $menu->getItems('component', 'com_search', true);
    93.  
    94.             // If we found a search page, use that.
    95.             if (!empty($item))
    96.             {
    97.                 $post['Itemid'] = $item->id;
    98.             }
    99.         }
    100.  
    101.         unset($post['task']);
    102.         unset($post['submit']);
    103.  
    104.         $uri = JUri::getInstance();
    105.         $uri->setQuery($post);
    106.         $uri->setVar('option', 'com_search');
    107.  
    108.         $this->setRedirect(JRoute::_('index.php' . $uri->toString(array('query', 'fragment')), false));
    109.     }
    110. }
    Как здесь из юрл убрать поисковой запрос и например заменить его словом search? Могу еще выложить router com_search и системный файл поиска компонента JoomSef.