1 (edited by ozero7 2016-05-26 07:25)

Topic: Some help with rewrite_rules.php and forum_urls.php?

Any help with these 2 problems I can't solve? Thanx in forward..

Problem 1:
I have file based url scheme and I am trying to change the names on rewrite_rules.php;
'forum' and 'topic' into 'text' and 'texts' in this rule:

'/^feed[\/_-]?(rss|atom)[\/_-]?(f|t)(orum|opic)[\/_-]?([0-9]+)[\/_-]?(\.xml?|\/)?$/i'                                    =>   

I tried this following but it doesn't work:
'/^feed[\/_-]?(rss|atom)[\/_-]?(t|t)(ext|exts)[\/_-]?([0-9]+)[\/_-]?(\.xml?|\/)?$/i'                                    =>   

Problem 2:
Another problem I can't solve is on forum_urls.php about this rule:
'topic'    =>    'texts$1-$2.php',

Is there a way to pick up just the first 3 words of variable $2 ?

So instead of: domain.com/texts18-any-help-with-these-problems.php
I want this: domain.com/texts18-any-help-with.php

2 (edited by PanBB.Ru 2016-05-26 07:41)

Re: Some help with rewrite_rules.php and forum_urls.php?

Use Function:

// $input_text - исходная строка
// $limit = 50 - количество слов по умолчанию
// $end_str - символ/строка завершения. Вставляется в конце обрезанной строки

function words_limit($input_text, $limit = 50, $end_str = '') {
    $input_text = strip_tags($input_text);
    $words = explode(' ', $input_text); // создаём из строки массив слов
    if ($limit < 1 || sizeof($words) <= $limit) { // если лимит указан не верно или количество слов меньше лимита, то возвращаем исходную строку
        return $input_text;
    $words = array_slice($words, 0, $limit); // укорачиваем массив до нужной длины
    $out = implode(' ', $words);
    return $out.$end_str; //возвращаем строку + символ/строка завершения

or regular expression..

3 (edited by ozero7 2016-05-26 13:01)

Re: Some help with rewrite_rules.php and forum_urls.php?

Thanx for the input but i tried a function like this before, but the problem on forum_urls.php is that the following is not possible:

'topic'    =>    'texts$1-'.words_limit('$2','50').'.php',

This doesn't work.
I am still getting:

Instead of:

4 (edited by PanBB.Ru 2016-05-26 15:10)

Re: Some help with rewrite_rules.php and forum_urls.php?


you are sure that the version 1.2 of your forum?

$forum_url = array(
     'topic'    =>    'texts$1-'.words_limit('$2','50').'.php'

within the array function can not be used .

Try to cut off the words before they fall into the array.
URL string does
for example

// Setup main heading
$forum_page['main_title'] = (($cur_topic['closed'] == '1') ? $lang_topic['Topic closed'].' ' : '').'<a class="permalink" href="'.forum_link($forum_url['topic'], array($id, sef_friendly($cur_topic['subject']))).'" rel="bookmark" title="'.$lang_topic['Permalink topic'].'">'.forum_htmlencode($cur_topic['subject']).'</a>';

sef_friendly(words_limit($cur_topic['subject']), 5)

5 (edited by ozero7 2016-05-26 20:22)

Re: Some help with rewrite_rules.php and forum_urls.php?

Making $forum_page['main_title'] shorter is indeed a good idea.
But between <title></title> tags i want to show whole title.
Only the url i want to be at maximum length of 3 words.

And sorry, my version is indeed 1.4.4.
I see know I ve posted on wrong side of this forum.
Maybe someone can move this post to 1.4.4. part of the forum.

Thanx again for your help.

6 (edited by PanBB.Ru 2016-05-26 20:54)

Re: Some help with rewrite_rules.php and forum_urls.php?

TITLE I took as an example . To do all you need to open viewforum.php.

And to do the work according to the principle of

    $forum_page['item_title']['link'] = '<a href="'.forum_link($forum_url['topic'], array($cur_topic['id'], sef_friendly($cur_topic['subject']))).'">'.forum_htmlencode($cur_topic['subject']).'</a>';

sef_friendly ( words_limit ( $ cur_topic [ 'субъект' ]),  5 )

Re: Some help with rewrite_rules.php and forum_urls.php?

thanx panbb, problem 2 is as good as solved, I ll figure it out further,

I ll post my problem 1 on the 1.4.4 version side of the forum.