Войдите, чтобы подписаться  

Как сделать IP.Content "корневым" приложением


Ritsuka

Чтобы сделать IP.Content первым, что открывается по заходу на ваш IP.Board-форум, нужно выполнить 2 шага:

 

1. Поднять форум и все его страницы из корня в виртуальную подпапку "forums" с помощью правки ЧПУ-шаблонов

 

Заменяем содержимое файла /admin/applications/forums/extensions/furlTemplates.php на:

 


* Invision Power Services
* IP.Board vVERSION_NUMBER
* Sets up SEO templates
* Last Updated: $Date: 2011-08-02 15:53:39 -0400 (Tue, 02 Aug 2011) $
* 
* * @author $Author: bfarber $ * @copyright (c) 2001 - 2009 Invision Power Services, Inc. * @license http://www.invisionpower.com/community/board/license.html * @package IP.Board * @subpackage Forums * @link http://www.invisionpower.com * @since 20th February 2002 * @version $Rev: 9351 $ * */ if ( ! defined( 'IN_IPB' ) ) { print "

Incorrect access

You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files."; exit(); } /** * SEO templates * * 'allowRedirect' is a flag to tell IP.Board whether to check the incoming link and if not formatted correctly, redirect the correct one * * OUT FORMAT REGEX: * First array element is a regex to run to see if we've a match for the URL * The second array element is the template to use the results of the parenthesis capture * * Special variable #{__title__} is replaced with the $title data passed to output->formatUrl( $url, $title) * * IMPORTANT: Remember that when these regex are used, the output has not been fully parsed so you will get: * showuser={$data['member_id']} NOT showuser=1 so do not try and match numerics only! * * IN FORMAT REGEX * * This allows the registry to piece back together a URL based on the template regex * So, for example: "/user/(\d+?)/", 'matches' => array( array( 'showuser' => '$1' ) )tells IP.Board to populate 'showuser' with the result * of the parenthesis capture #1 */ $_SEOTEMPLATES = array( 'showannouncement' => array( 'app' => 'forums', 'allowRedirect' => 1, 'out' => array( '#showannouncement=(.+?)((?:&|&)f=(.+?))?(&|$)#i', 'forums/forum-$3/announcement-$1-#{__title__}/$4' ), 'in' => array( 'regex' => '#/forums/forum-(\d+?)?/announcement-(\d+?)-#i', 'matches' => array( array( 'showannouncement', '$2' ), array( 'f', '$1' ) ) ) ), 'showforum' => array( 'app' => 'forums', 'allowRedirect' => 1, 'isPagesMode' => 1, 'out' => array( '#showforum=(.+?)(&|$)#i', 'forums/forum/$1-#{__title__}/$2' ), 'in' => array( 'regex' => '#^/forums/forum/(\d+?)-#i', 'matches' => array( array( 'showforum', '$1' ) ) ) ), 'showtopicunread'=> array( 'app' => 'forums', 'allowRedirect' => 1, 'out' => array( '#showtopic=(.+?)(?:&|&)view=getnewpost(&|$)#i', 'forums/topic/$1-#{__title__}/unread/$2' ), 'in' => array( 'regex' => '#^/forums/topic/(\d+?)-([^/]+?)/unread(/|$)#i', 'matches' => array( array( 'showtopic', '$1' ), array( 'view', 'getnewpost' ) ) ) ), 'showtopicnextunread'=> array( 'app' => 'forums', 'allowRedirect' => 1, 'out' => array( '#showtopic=(.+?)(?:&|&)view=getnextunread(&|$)#i', 'forums/topic/$1-#{__title__}/nextunread/$2' ), 'in' => array( 'regex' => '#^/forums/topic/(\d+?)-([^/]+?)/nextunread(/|$)#i', 'matches' => array( array( 'showtopic', '$1' ), array( 'view', 'getnextunread' ) ) ) ), 'showtopic' => array( 'app' => 'forums', 'allowRedirect' => 1, 'isPagesMode' => 1, 'out' => array( '#showtopic=(.+?)(\#|&|$)#i', 'forums/topic/$1-#{__title__}/$2' ), 'in' => array( 'regex' => '#^/forums/topic/(\d+?)-#i', 'matches' => array( array( 'showtopic', '$1' ) ) ) ), 'acteqst' => array( 'app' => 'forums', 'allowRedirect' => 1, 'out' => array( '#act=ST(.*?)&t=(.+?)(&|$)#i', 'forums/topic/$2-#{__title__}/$3' ), 'in' => array( 'regex' => '#^notavalidrequest$#i', 'matches' => array( array( 'showtopic', '0' ) ) ) ), 'act=idx' => array( 'app' => 'forums', 'allowRedirect' => 0, 'out' => array( '#act=idx(&|$)#i', 'forums/$1' ), 'in' => array( 'regex' => '#^/forums(/|$|\?)#i', 'matches' => array( array( 'act', 'idx' ) ) ) ), );

 

 

2. Назначаем IP.Content основным приложением

 

Заменяем в /initdata.php это:

 

/**
* Default app name
* You can set this in your own scripts before 'initdata.php' is required.
*/
if ( ! defined( 'IPS_DEFAULT_PUBLIC_APP' ) )
{
define( 'IPS_DEFAULT_PUBLIC_APP', 'forums' );
}

 

 

на это:

 

/**
* Default app name
* You can set this in your own scripts before 'initdata.php' is required.
*/
if ( ! defined( 'IPS_DEFAULT_PUBLIC_APP' ) )
{
define( 'IPS_DEFAULT_PUBLIC_APP', 'ccs' );
}

 

 

3. Сбрасываем кэш ЧПУ (одноименная кнопка в админке)

 

4. Делаем первой вкладкой в меню наш сайт на IP.Content (опционально)

 

В шаблоне Global Templates > globalTemplate находим:

 

 

 

Заменяем на:

 

						{parse variable="ccsActive" default="" oncondition="IPS_APP_COMPONENT == 'ccs'" value="active"}
					

 

 

Адрес и текст этой ссылки задаются в настройках, в группе "General Configuration", поля Website name и Website address. В принципе, если скинов не много, можно сразу написать:

 

						{parse variable="ccsActive" default="" oncondition="IPS_APP_COMPONENT == 'ccs'" value="active"}
					

 

 

В настройках IP.Content выставляем "Show 'Pages' navigation bar entry" на "No".

 

Результат

 

Теперь у вас все несуществующие адреса будут передаваться в IP.Content, который будет либо выдавать текстовую ошибку 404, либо показывать с тем же 404-заголовком любую назначенную вами страницу IP.Content. Главная страница IP.Content (по-умолчанию - index.html, меняется в настройках) станет главной страницей всего форума. Список форумов уйдет на подпапку "/forums/", все остальные приложения останутся в своих подпапках.

 

Итоговая структура:

/ - IP.Content
/forums/forum/ - Форум
/forums/topic/ - Темы
/blogs/ - Блоги
/gallery/ - Галерея
и т.д.

 

Примечание! Если вам нужно только назначить IP.Content как приложение по умолчанию (главной страницы), достаточно выполнить только второй пункт.

Статья рассказывает о именно том, как создать эффект "корневого" приложения, когда форум визуально находится в виртуальную папку /forums/

Войдите, чтобы подписаться  
Перейти к статьи


Отзывы пользователей

Рекомендованные комментарии

Нет комментариев для отображения