Уважаемые пользователи!
C 7 ноября 2020 года phpBB Group прекратила выпуск обновлений и завершила дальнейшее развитие phpBB версии 3.2.
С 1 августа 2024 года phpBB Group прекращает поддержку phpBB 3.2 на официальном сайте.
Сайт официальной русской поддержки phpBB Guru продолжит поддержку phpBB 3.2 до 31 декабря 2024 года.
С учетом этого, настоятельно рекомендуется обновить конференции до версии 3.3.

topic dir

Вопросы без привязки к версии. Установлена авточистка (2 года).
Правила форума
Местная Конституция | Шаблон запроса | Документация (phpBB3) | Переход на 3.0.6 и выше | FAQ | Как задавать вопросы | Как устанавливать расширения

Ваш вопрос может быть удален без объяснения причин, если на него есть ответы по приведённым ссылкам (а вы рискуете получить предупреждение ;) ).
php_bb
phpBB 1.4.2
Сообщения: 72
Стаж: 3 года 9 месяцев
Благодарил (а): 35 раз

topic dir

Сообщение php_bb »

Hi,
please give me the modification or if its possible give me the code for [event\listener.php] for extension to do this:

- when i visit topic[342], topic[355] and topic[182], the direction of posts changes to [Descending].

thank you,
Regards
php_bb
phpBB 1.4.2
Сообщения: 72
Стаж: 3 года 9 месяцев
Благодарил (а): 35 раз

Re: topic dir

Сообщение php_bb »

any help please?
Regards
Аватара пользователя
Sheer
Former team member
Сообщения: 12113
Стаж: 17 лет 2 месяца
Откуда: Калининград не Кенигсберг
Благодарил (а): 41 раз
Поблагодарили: 1716 раз

Re: topic dir

Сообщение Sheer »

Правила, пункт: 3.5. Запрещается "поднимать" интересующую вас тему (т. е. посылать не несущее информационной нагрузки сообщение) в течение 5 суток с момента последнего ответа в тему. Помните, что люди тоже работают, устают, отдыхают, огорчаются и радуются, и не забудьте о качестве и постоянстве услуг связи.
Изображение
Общие ошибки новичков (07.11.2005) & Как задавать вопросы
Мини FAQ
Если ничто другое не помогает, прочтите, наконец, инструкцию!
"Никакая инструкция не может перечислить всех обязанностей должностного лица, предусмотреть все отдельные случаи и дать вперёд соответствующие указания, а поэтому господа инженеры должны проявить инициативу и, руководствуясь знаниями своей специальности и пользой дела, принять все усилия для оправдания своего назначения".
Циркуляр Морского технического комитета №15 от 29.11.1910 г.
php_bb
phpBB 1.4.2
Сообщения: 72
Стаж: 3 года 9 месяцев
Благодарил (а): 35 раз

Re: topic dir

Сообщение php_bb »

if i can't do with extension, please direct me to the php file that controls this function! thanks
Regards
php_bb
phpBB 1.4.2
Сообщения: 72
Стаж: 3 года 9 месяцев
Благодарил (а): 35 раз

Re: topic dir

Сообщение php_bb »

UCP setting we can change this based on user.
but i wanna do this based on the topic!
if i find the php file that controls this, then i can put a condition to do based on the topic.
is there any event to do this? if no, where is exactly the code to do this?
thanks,
Regards
Аватара пользователя
Pazh
Former team member
Сообщения: 2317
Стаж: 14 лет 5 месяцев
Благодарил (а): 37 раз
Поблагодарили: 261 раз

Re: topic dir

Сообщение Pazh »

php_bb, all events shown in *.php files: for topics - in viewtopic.php, for ucp - in ucp.php
Find extract($phpbb_dispatcher->trigger_event( code and look some lines before - this is event and description of event. There are many events in one php file
Помощь в ЛС/email только за WM или ЮMoney
Аватара пользователя
rxu
phpBB Guru
phpBB Guru
Сообщения: 16367
Стаж: 17 лет 11 месяцев
Откуда: Красноярск
Благодарил (а): 521 раз
Поблагодарили: 1744 раза

Re: topic dir

Сообщение rxu »

Изображение
php_bb
phpBB 1.4.2
Сообщения: 72
Стаж: 3 года 9 месяцев
Благодарил (а): 35 раз

Re: topic dir

Сообщение php_bb »

Pazh писал(а): 24.01.2021 13:11events
i found the event, its [core.viewtopic_gen_sort_selects_before]. and replaced the direction with: sort_dir thank you :)
now i have one problem. i cant get topic-id with this event to check the topics that i wanna change their directions.
with [core.viewtopic_get_post_data] i can get the topic-id, but i dont know how to pass the topic-id from this method to that method to check the topic-ids.
how can i check topics: [342,355,182], and then apply post direction?
Regards
Аватара пользователя
Pazh
Former team member
Сообщения: 2317
Стаж: 14 лет 5 месяцев
Благодарил (а): 37 раз
Поблагодарили: 261 раз

Re: topic dir

Сообщение Pazh »

php_bb, you must use for example event 'core.viewtopic_before_f_read_check' for checking topic_id and save it in listener's variable like this

Код: Выделить всё

protected $is_my_topic; //declare "global" variable in listener.php

public function viewtopic_before_f_read_check($event)
{
	if(in_array($event['topic_id'],[342,355,182]))
	{
		$this->is_my_topic = true;
	}
	else
	{
		$this->is_my_topic = false;
	}		
}
and then in event viewtopic_gen_sort_selects_before check variable $this->is_my_topic for example

Код: Выделить всё

public function viewtopic_gen_sort_selects_before($event)
{
	if($this->is_my_topic && $event['sort_dir'] != 'd')
	{
		$event['sort_dir'] = 'd';
	}
}
Помощь в ЛС/email только за WM или ЮMoney
php_bb
phpBB 1.4.2
Сообщения: 72
Стаж: 3 года 9 месяцев
Благодарил (а): 35 раз

Re: topic dir

Сообщение php_bb »

Pazh писал(а): 24.01.2021 15:51you must
Thank you very much @Pazh. it worked very well! :)
Regards
php_bb
phpBB 1.4.2
Сообщения: 72
Стаж: 3 года 9 месяцев
Благодарил (а): 35 раз

Re: topic dir

Сообщение php_bb »

Pazh писал(а): 24.01.2021 15:51you must
@Pazh
I applied this to one of the topics. To [Descending].
Now when i post a new reply to that topic:
1. it redirects to the end page of the topic. Not to the first page of the topic. Because now the topic's post direction is descending and it should redirect to the first page of the topic.
2. When i click on the topic's url: https://mysite.com/viewtopic.php?p=122#p122
It goes to the ascending page location of post. Not descending.
Do you know how to solve this issue?
Regards
php_bb
phpBB 1.4.2
Сообщения: 72
Стаж: 3 года 9 месяцев
Благодарил (а): 35 раз

Re: topic dir

Сообщение php_bb »

When we change the topic's post direction in UCP, there is no problem with post's url redirection. But changing with extension, it has this issue. why?
Where is the core code that corrects this issue when we set it with UCP?
Regards
php_bb
phpBB 1.4.2
Сообщения: 72
Стаж: 3 года 9 месяцев
Благодарил (а): 35 раз

Re: topic dir

Сообщение php_bb »

How can i put 'd' value for url redirection also? Like: $event['sort_dir'] = 'd';
Regards
php_bb
phpBB 1.4.2
Сообщения: 72
Стаж: 3 года 9 месяцев
Благодарил (а): 35 раз

Re: topic dir

Сообщение php_bb »

I couldn't be able to do this. Because this event has this bug. It doesn't set the direction entirely and properly with [$event['sort_dir']]
Please someone reports to the phpbb team to fix this issue.
I just edited the core code to do this and its working with no problem.
I will do it by extension later if this event be fixed.
Thank you,
Regards
Аватара пользователя
rxu
phpBB Guru
phpBB Guru
Сообщения: 16367
Стаж: 17 лет 11 месяцев
Откуда: Красноярск
Благодарил (а): 521 раз
Поблагодарили: 1744 раза

Re: topic dir

Сообщение rxu »

This is because you do it wrong way. The value can't be assigned directly in the listener but via intermediate variable.

Код: Выделить всё

$sort_dir = $event['sort_dir'];
$sort_dir = 'd';
$event['sort_dir'] = $sort_dir;
$event variable first should be copied by assigning it to a local variable, then modified, and then copied back. Shortcut like $event['sort_dir'] = 'd'; does not work because the event variables are overloaded, which is a limitation in PHP.
Изображение

Вернуться в «phpBB-пространство»