Настройка ЧПУ для фриланс-биржи на Cotonti

Данный мануал позволяет настроить ЧПУ для вашей фриланс-биржи. ЧПУ также включает настройки для разделов фрилансеров и работодателей, которые позволяют использовать дружественные ссылки

Данный мануал позволяет настроить ЧПУ для вашей фриланс-биржи. ЧПУ также включает настройки для разделов фрилансеров и работодателей, которые позволяют заменить ссылки типа users/?group=freelancer на freelancers/

Для настройки ЧПУ для фриланс-биржи необходимо первым делом установить плагин URLeditor, который входит в сборку.

1) После этого в директорию plugins/urleditor/presets/ необходимо загрузить пресет-файл с правилами формирования ссылок назовем его myconfig.dat

Файл содержит следующий код:

forums    m=posts&q=&d=    forums/{forums_url_structure()}/page{$d}
forums    m=posts&q=*    forums/{forums_url_structure()}
forums    m=posts&id=*    forums/{forums_url_structure()}
forums    m=topics&s=&d=    forums/{forums_url_structure()}/page{$d}{!$m}
forums    m=topics&s=*    forums/{forums_url_structure()}{!$m}
forums    c=*    forums/{$c}
forums    *    forums
page    m=*                        page?m={$m}
page    c=system&al=*            {$al}{!$c}
page    c=*&al=*                {cot_url_catpath()}/{$al}
page    c=*&id=*                {cot_url_catpath()}/{$id}
page    c=*                        {cot_url_catpath()}
index    *                        {$_path}
plug    e=tags&a=pages&t=*        {$e}/{$t}{!$a}
plug    e=tags&a=*&t=*            {$e}/{$a}/{$t}
plug    e=*                        {$e}
users    group=employer&cat=*            employers/{$cat}/{!$group}
users    group=freelancer&cat=*            freelancers/{$cat}/{!$group}
users    group=employer            employers/{!$group}
users    group=freelancer            freelancers/{!$group}
users    m=details&u=*            users/{cot_url_username()}
login    *                        {$_area}
message    *                        {$_area}
admin    m=*                        admin/{$m}
admin    *                        {$_area}
rss        m=*&c=*                    {$_area}/{$m}/{$c}
rss        m=*&id=*                {$_area}/{$m}/{$id}
rss        c=*                        {$_area}/{$c}
rss        m=*                        {$_area}/{$m}
*        c=*&al=*                {$_area}/{cot_url_catpath()}/{$al}
*        c=*&id=*                {$_area}/{cot_url_catpath()}/{$id}
*        c=*                        {$_area}/{cot_url_catpath()}
*        al=*                    {$_area}/{$al}
*        id=*                    {$_area}/{$id}
*        *                        {$_area}

 

В директории system/ создаем файл functions.custom.php с кодом функции forums_url_structure() для подключения библиотеки дополнительных функций. Подключить его можно в конфиг-файле datas/config.php Для этого установите переменную $cfg['customfuncs'] в значение true:

$cfg['customfuncs'] = TRUE;

В этом файле должна присутствовать следующая функция:

function forums_url_structure(&$args)
{
    global $cfg, $db, $structure, $db_forum_topics, $db_forum_posts;

	require_once cot_incfile('forums', 'module');
	
    $script = 'forums';
    $replacement = '';
    if(isset($args['m']) && $args['m'] == 'topics')
    {
        if(isset($args['s']))
        {
			$d = (int) $args['d'];
			
            $replacement .= str_replace('.', '/', $structure['forums'][$args['s']]['path']);
			
			if(isset($args['d']))
			{
				$replacement .= '/page'.$d;
			}
			
			unset($args['d']);
			unset($args['s']);
        }
        else $replacement .= $script;
    }
    elseif(isset($args['m']) && $args['m'] == 'posts')
    {
        if(isset($args['q']))
        {
            $q = (int) $args['q'];
            $d = (int) $args['d'];
            $s = $db->query("SELECT fp_cat FROM $db_forum_posts WHERE fp_topicid=".$q)->fetchColumn();
            
			$replacement .= str_replace('.', '/', $structure['forums'][$s]['path']).'/topic'.$q;
			
			if(isset($args['d']))
			{
				$replacement .= '/page'.$d;
			}
			
			unset($args['d']);
			unset($args['q']);
            unset($args['m']);
        }
        elseif(isset($args['id']))
        {
            $id = (int) $args['id'];
            $s = $db->query("SELECT fp_cat FROM $db_forum_posts WHERE fp_id=".$id)->fetchColumn();
			
            $replacement .= str_replace('.', '/', $structure['forums'][$s]['path']).'/post'.$id;
			
            unset($args['id']);
            unset($args['m']);
        }
        else $replacement .= $script;
    }
    else $replacement .= $script;
    return $replacement;
}

 

2) После этого обязательно нужно изменить коневой файл .htaccess либо заменить его на наш: .htaccess

Файл содержит следующий код:

################ Cotonti Handy URLs for Apache #######################

# Below are the rules to be included in your main .htaccess file or httpd.conf

# Rewrite engine options
Options -Indexes
RewriteEngine On

# Server-relative path to Cotonti. Replace it with your path if you run Cotonti
# in a subfolder
RewriteBase "/"

# Language selector
RewriteRule ^(en|ru|de|nl)/(.*) $2?l=$1 [QSA,NC,NE]

# Sitemap shortcut
RewriteRule ^sitemap\.xml$ index.php?r=sitemap [L]

# Admin area and message are special scripts
RewriteRule ^admin/([a-z0-9]+) admin.php?m=$1 [QSA,NC,NE,L]
RewriteRule ^(admin|login|message)(/|\?|$) $1.php [QSA,NC,NE,L]

# users
RewriteRule ^employers/?$ index.php?e=users&group=employer [QSA,NC,NE,L]
RewriteRule ^freelancers/?$ index.php?e=users&group=freelancer [QSA,NC,NE,L]
RewriteRule ^employers/([a-zA-Z0-9_./%-]+)/?$ index.php?e=users&group=employer&cat=$1 [QSA,NC,NE,L]
RewriteRule ^freelancers/([a-zA-Z0-9_./%-]+)/?$ index.php?e=users&group=freelancer&cat=$1 [QSA,NC,NE,L]

# forums
RewriteRule ^forums/([a-zA-Z0-9_./%-]+)/topic([0-9]+)/page([0-9]+)?$ index.php?e=forums&m=posts&q=$2&d=$3 [QSA,NC,NE,L]
RewriteRule ^forums/([a-zA-Z0-9_./%-]+)/topic([0-9]+)?$ index.php?e=forums&m=posts&q=$2 [QSA,NC,NE,L]
RewriteRule ^forums/([a-zA-Z0-9_./%-]+)/post([0-9]+)?$ index.php?e=forums&m=posts&id=$2 [QSA,NC,NE,L]
RewriteRule ^forums/([a-zA-Z0-9_./%-]+)/([a-zA-Z0-9_%-]+)/page([0-9]+)?$ index.php?e=forums&m=topics&s=$2&d=$3 [QSA,NC,NE,L]
RewriteRule ^forums/([a-zA-Z0-9_./%-]+)/([a-zA-Z0-9_%-]+)/?$ index.php?e=forums&m=topics&s=$2 [QSA,NC,NE,L]
RewriteRule ^forums/([a-zA-Z0-9_%-]+)/?$ index.php?e=forums&c=$1 [QSA,NC,NE,L]
RewriteRule ^forums/?$ index.php?e=forums [QSA,NC,NE,L]

# System category has priority over /system folder
RewriteRule ^system/?$  index.php?rwr=system [QSA,NC,NE,L]

# All the rest goes through standard rewrite gateway
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]+) index.php?rwr=$1 [QSA,NC,NE,L]

 

3) Далее в настройках плагина Urleditor необходимо выбрать ваш пресет-файл, который вы создали в пункте 1.

 

Примечание: 

  1. По-умолчанию в сборке фриланс-биржи группы фрилансеров и работодателей имеют алиасы: freelancer и employer, соответственно. Если на вашем сайте алиасы групп имеют другое значение, то необходимо их также изменить в файлах (myconfig.dat и .htaccess). Алиас группы можно изменить в админке в разделе "Пользователи" по ссылке "Правка" напротив нужной группы.
  2. Также обратите внимание, что после включения ЧПУ по данной инструкции, также необходимо будет поправить ссылки в основном меню сайта. для этого нужно заменить в шаблоне header.tpl ссылки на каталоги фрилансеров и работодателей. Пример ссылок:
    <li<!-- IF {PHP.env.ext} == 'users' AND ({PHP.group} == {PHP.cot_groups.4.alias} AND {PHP.m} == 'main' --> class="active"<!-- ENDIF -->><a href="{PHP.cot_groups.4.alias|cot_url('users', 'group='$this)}">{PHP.cot_groups.4.name}</a></li>
    <li<!-- IF {PHP.env.ext} == 'users' AND ({PHP.group} == {PHP.cot_groups.7.alias} AND {PHP.m} == 'main' --> class="active"<!-- ENDIF -->><a href="{PHP.cot_groups.7.alias|cot_url('users', 'group='$this)}">{PHP.cot_groups.7.name}</a></li>

 

4 minutes read Sodium Carbonate

Comments (0)

No comments yet
Only registered users can post new comments

Content author

webitproff

Offline

Sodium Carbonate

Last logged: 2026-09-03 18:32

About me briefly
Support and development of web projects on the CMF Cotonti: private messengers via the website, open and closed small social networks, trading platforms and marketplaces, freelance and services exchange portal, catalogs of goods from wholesale suppliers, dropshipping platforms, online stores, and much more.
View developments and download
Public portfolio of my works and developments
Telegram for messages
@webitproff
Telegram channel
@s/aBuyFILE
  • Page published: 2024-09-14 15:39
  • Last update: 2024-09-14 15:39

Similar pages

Настройка ЧПУ с форумом на CMF Cotonti
1 Внимание! Эта инструкция только для простых сайтов на Cotonti. Если вам нужно настроить ЧПУ для фриланс-биржи, то
Настройка структуры сайта фриласн биржи
2 Настройка структуры сайта фриласн биржи Категории проектов Для организации структуры проектов сайта зайдите в
Полное руководство по настройке ЧПУ для модуля Forums в Cotonti
3 Это руководство поможет вам настроить красивые URL для разделов, тем и сообщений форума Cotonti. В результате
Инструкция по установке фриланс-биржи на CMF Cotonti.
4 1. Распакуйте исходники в корневую директорию вашего сайта. 2. Создайте в директории datas/ файл config.php и
Описание функционала фриланс-биржи на CMF Cotonti.
5 Описание функционала фриланс-биржи Сборка фриланс-биржи на базе Cotonti Siena. С помощью данной сборки можно