Jump to content
Дизайн и модификация Invision Community IPBSkinsBETA
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
vinegredz

Как указать ссылку на редирект при создании новой записи в CMS?

Recommended Posts

Здравствуйте!

 

По умолчанию при создании новой записи в любой базе данных, после отправки формы происходит редирект на страницу только что созданной, новой записи.

 

Вопрос, как изменить ссылку по которой будет редирект после отправки формы?

Share this post


Link to post

По умолчанию при создании новой записи в любой базе данных, после отправки формы происходит редирект на страницу только что созданной, новой записи.

 

Не только для записей, но и для тем, лс и т.п.

 

\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(''); // перенаправляем на главную страницу
	}

Share this post


Link to post

Спасибо за ответ.

 

Открыл файл \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;
   }

 

К сожалению, не перенаправляет на главную.

Share this post


Link to post

Оставьте

if (\IPS\Request::i()->do == 'form')

Я когда смотрел, заходил из категории. А там добавляется параметр d

Share this post


Link to post

Работает! Большое спасибо!

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...