Forums / National / Russian / Тех. поддержка / Запросы документации

Принимаем вопросы от населения

kap3
#43033 2017-09-25 12:54
#43032 Roffun:

Проверьте наличие файла /system/functions.custom.php , присутствия в нем функции forums_url_structure().

Также проверьте в файле конфигурации /datas/config.php включение этого файла:  $cfg['customfuncs'] = true;

Спасибо за ответ, но дело было в другом, просто часть код function forums_url_structure(&$args)

нужно вставляет в начале а потом function cot_load_structure_custom()

вот рабочий вариант  functions.custom.php 

Чтобы не нарушать права правообладателя оставлю ссылку на исходник,  Настройка ЧПУ для фриланс-биржи на Cotonti  https://cotonti.cmsworks.ru/docs/docs-apps/freelance2-docs/chpu-for-freelance

<?php

defined('COT_CODE') or die('Wrong URL');
/**
 * Forum URL overrides
 *
 * @param array $args Args passed over from cot_url
 * @return string
 */
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;
}
	
function cot_load_structure_custom()
{
	global $db, $db_structure, $cfg, $cot_extrafields, $structure;
	$structure = array();
	if (defined('COT_UPGRADE'))
	{
		$sql = $db->query("SELECT * FROM $db_structure ORDER BY structure_path ASC");
		$row['structure_area'] = 'page';
	}
	else
	{
		$sql = $db->query("SELECT * FROM $db_structure ORDER BY structure_area ASC, structure_path ASC");
	}

	/* == Hook: Part 1 ==*/
	$extp = cot_getextplugins('structure');
	/* ================= */

	$path = array(); // code path tree
	$tpath = array(); // title path tree
	$tpls = array(); // tpl codes tree

	foreach ($sql->fetchAll() as $row)
	{
		$last_dot = mb_strrpos($row['structure_path'], '.');

		$row['structure_tpl'] = empty($row['structure_tpl']) ? $row['structure_code'] : $row['structure_tpl'];

		if ($last_dot > 0)
		{
			$path1 = mb_substr($row['structure_path'], 0, $last_dot);
			$path[$row['structure_path']] = $path[$path1] . '.' . $row['structure_code'];
			$separaror = ($cfg['separator'] == strip_tags($cfg['separator'])) ? ' ' . $cfg['separator'] . ' ' : ' \ ';
			$tpath[$row['structure_path']] = $tpath[$path1] . $separaror . $row['structure_title'];
			$parent_dot = mb_strrpos($path[$path1], '.');
			$parent = ($parent_dot > 0) ? mb_substr($path[$path1], $parent_dot + 1) : $path[$path1];
			$subcats[$row['structure_area']][$parent][] = $row['structure_code'];
		}
		else
		{
			$path[$row['structure_path']] = $row['structure_code'];
			$tpath[$row['structure_path']] = $row['structure_title'];
			$parent = $row['structure_code']; // self
		}

		if ($row['structure_tpl'] == 'same_as_parent')
		{
			$row['structure_tpl'] = $tpls[$parent];
		}

		$tpls[$row['structure_code']] = $row['structure_tpl'];

		$structure[$row['structure_area']][$row['structure_code']] = array(
			'path' => $path[$row['structure_path']],
			'tpath' => $tpath[$row['structure_path']],
			'rpath' => $row['structure_path'],
			'id' => $row['structure_id'],
			'tpl' => $row['structure_tpl'],
			'title' => $row['structure_title'],
			'desc' => $row['structure_desc'],
			'icon' => $row['structure_icon'],
			'locked' => $row['structure_locked'],
			'count' => $row['structure_count']
		);

		if (is_array($cot_extrafields[$db_structure]))
		{
			foreach ($cot_extrafields[$db_structure] as $exfld)
			{
				$structure[$row['structure_area']][$row['structure_code']][$exfld['field_name']] = $row['structure_'.$exfld['field_name']];
			}
		}

		/* == Hook: Part 2 ==*/
		foreach ($extp as $pl)
		{
			include $pl;
		}
		/* ================= */
	}

	foreach ($structure as $area => $area_structure)
	{
		foreach ($area_structure as $i => $x)
		{
			$structure[$area][$i]['subcats'] = $subcats[$area][$i];
		}
	}
}
?>

 

This post was edited by kap3 (2017-09-25 13:17, 6 years ago)