1. Приветствуем Вас на неофициальном форуме технической поддержки XenForo на русском языке. XenForo - коммерческий форумный движок от бывших создателей vBulletin, написанный на PHP.

[Library] Set your own Route/Controller as Homepage

Тема в разделе "Плагины для XenForo [1.x]", создана пользователем Сергей Александров, 08.12.2011.

Загрузка
  1. Сергей Александров

    Сергей Александров Местный

    Регистрация:
    09.01.11
    Сообщения:
    27
    Симпатии:
    4
    [Library] Set your own Route/Controller as Homepage

    Тема на оф. форуме:
    Код:
    http://xenforo.com/community/threads/library-set-your-own-route-controller-as-homepage.10156/
    Автор: Shadab
    Описание: установка собственного пути/контроллера к домашней странице.
    Установка:
    1. Залить файлы.
    Использование/API

    There's only one static method which you need to call. The first argument (type: Zend_Config) is the configuration data you need to pass; and the second argument (type: array) is the dependency data supplied by init_dependencies.
    GeekPoint_CustomIndex_Helper::setDefaultRoute($config, $data);

    Конфигурация

    routePrefix
    This is the route prefix which you want to set as the default. Suppose you set the "foo" route-prefix as default, any links generated for "foo" or "foo/index" will now point to the homepage "/".​

    controllerClass
    This is the controller class which will handle the homepage. Specifically, the actionIndex() method in your controller will be responsible for generating the homepage.​

    majorSection
    [Optional] The major section-name, used when generating the route-match for homepage.​

    minorSection
    [Optional] The minor section-name, used when generating the route-match for homepage.​

    params
    [Optional] Parameters that will be added to the request object during the routing process. This enables you to set any content which depends upon a request parameter to be present, as your homepage. For example: node "Pages", or Threads (yes, threads! But for heaven's sake don't do that.)

    Примеры

    Create a new event-listener for init_dependencies. Then in your callback method, just set the configuration options, and call the helper. That's it. Some examples are given below, starting with the code for setting "Recent Activity" as your homepage...
    PHP:
    public static function initDependencies(XenForo_Dependencies_Abstract $dependencies, array $data)
    {
        if (!
    $dependencies instanceof XenForo_Dependencies_Public)
        {
            return;
        }
     
        
    $config = new Zend_Config(array(
            
    'routePrefix'    => 'recent-activity',
            
    'controllerClass' => 'XenForo_ControllerPublic_RecentActivity',
        ));
     
        
    GeekPoint_CustomIndex_Helper::setDefaultRoute($config$data);
    }
    @Jaxel:
    Configuration for setting the portal page as homepage...

    (No other changes required.)
    PHP:
        $config = new Zend_Config(array(
            
    'routePrefix'    => 'portal',
            
    'controllerClass' => 'EWRporta_ControllerPublic_Portal',
            
    'majorSection'    => 'portal'
        
    )); 
    @Brogan:
    Configuration for setting a node page as the homepage.

    (Replace "lectus-pretium-consequat" with your node name. Any changes that you make to the page name via Admin Panel need to be reflected in this config array.)

    PHP:
        $config = new Zend_Config(array(
            
    'routePrefix'    => 'pages',
            
    'controllerClass' => 'XenForo_ControllerPublic_Page',
            
    'params'          => array('node_name' => 'lectus-pretium-consequat'),
        )); 
     

    Вложения:

  2. Romchik®

    Romchik® The Power of Dreams Команда форума

    Регистрация:
    26.09.10
    Сообщения:
    5 746
    Симпатии:
    5 311
    Версия XF:
    1.5.18
    Вложение добавлено, тема перемещена.
     
    Сергей Александров нравится это.
  3. Сергей Александров

    Сергей Александров Местный

    Регистрация:
    09.01.11
    Сообщения:
    27
    Симпатии:
    4
    Друзья, подскажите. Сделал при помощи этого аддона главной страницей один из разделов форума. Всё гуд. Главная при этом переехала в /forum/. Но, например, при разлогивании юзера перенаправляет на site.com/forum/, а нужно на site.com, т.к. site.com/forum/ видеть вобще никто не должен.

    Что поковырять можно?
     

Поделиться этой страницей