vinegredz Posted July 11, 2018 Share Posted July 11, 2018 Здравствуйте! По умолчанию при создании новой записи в любой базе данных, после отправки формы происходит редирект на страницу только что созданной, новой записи. Вопрос, как изменить ссылку по которой будет редирект после отправки формы? Link to comment Share on other sites More sharing options...
newbie Posted July 11, 2018 Share Posted July 11, 2018 По умолчанию при создании новой записи в любой базе данных, после отправки формы происходит редирект на страницу только что созданной, новой записи. Не только для записей, но и для тем, лс и т.п. \system\Content\Item.php if ( !\IPS\Member::loggedIn()->member_id and $obj->hidden() ) { \IPS\Output::i()->redirect( $obj->container()->url(), 'mod_queue_message' ); } else if ( $obj->hidden() == 1 ) { \IPS\Output::i()->redirect( $obj->url(), 'mod_queue_message' ); } else { \IPS\Output::i()->redirect( $obj->url() ); }Проверяйте, что это статья и перенаправляйте по новому адресу Либо \applications\cms\sources\Records\Records.php public function url( $action=NULL ) {Проверяйте параметры и перенаправляйте по новому адресу. Что-то вроде public function url( $action=NULL ) { if (\IPS\Request::i()->do == 'form' and isset(\IPS\Request::i()->d)) { return \IPS\Http\Url::internal(''); // перенаправляем на главную страницу } Link to comment Share on other sites More sharing options...
vinegredz Posted July 11, 2018 Author Share Posted July 11, 2018 Спасибо за ответ. Открыл файл \applications\cms\sources\Records\Records.php Сделал такой код: public function url( $action=NULL ) { if (\IPS\Request::i()->do == 'form' and isset(\IPS\Request::i()->d)) { return \IPS\Http\Url::internal(''); // перенаправляем на главную страницу } if ( ! $this->recordPage ) { /* If we're coming through the database controller embedded in a page, $currentPage will be set. If we're coming in via elsewhere, we need to fetch the page */ try { $this->recordPage = \IPS\cms\Pages\Page::loadByDatabaseId( static::$customDatabaseId ); } catch( \OutOfRangeException $ex ) { if ( \IPS\cms\Pages\Page::$currentPage ) { $this->recordPage = \IPS\cms\Pages\Page::$currentPage; } else { throw new \LogicException; } } } if ( $this->recordPage ) { $pagePath = $this->recordPage->full_path; $class = '\IPS\cms\Categories' . static::$customDatabaseId; $catPath = $class::load( $this->category_id )->full_path; $recordSlug = ! $this->record_static_furl ? $this->record_dynamic_furl . '-r' . $this->primary_id_field : $this->record_static_furl; if ( static::database()->use_categories ) { $url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=page&path=" . $pagePath . '/' . $catPath . '/' . $recordSlug, 'front', 'content_page_path', $recordSlug ); } else { $url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=page&path=" . $pagePath . '/' . $recordSlug, 'front', 'content_page_path', $recordSlug ); } } if ( $action ) { $url = $url->setQueryString( 'do', $action ); $url = $url->setQueryString( 'd' , static::database()->id ); $url = $url->setQueryString( 'id', $this->primary_id_field ); } return $url; } К сожалению, не перенаправляет на главную. Link to comment Share on other sites More sharing options...
newbie Posted July 11, 2018 Share Posted July 11, 2018 Оставьте if (\IPS\Request::i()->do == 'form')Я когда смотрел, заходил из категории. А там добавляется параметр d Link to comment Share on other sites More sharing options...
vinegredz Posted July 11, 2018 Author Share Posted July 11, 2018 Работает! Большое спасибо! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now