Перейти к публикации
View in the app

A better way to browse. Learn more.

Дизайн и модификация Invision Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Изменение main блока Portal 1.4

Опубликовано:

Хочу отредактировать центральный блок портала (Latest Topics Main)

Чтобы он показывал не последние созданые топики, а последние посты с топиков!

Там как бы в настройках есть Topics default order: там можно менять Topic Start Date и Last Reply Date меняю на Last Reply Date он как бы показывает последние топики где написали но содержимое первого поста, надо последний пост...

 

Я думая надо тут менять \admin\applications_addon\other\portal\sources\blocks.php

 

	public function latest_topics_main()
	{
		//-----------------------------------------
		// INIT
		//-----------------------------------------

		$attach_pids	= array();
		$attach_posts	= array();
		$forums			= array();
		$topics			= array();
		$output			= array();
	$where_clause	= array();
		$limit			= $this->settings['latest_topics_main'] ? intval( $this->settings['latest_topics_main'] ) : 3;
		$posts			= intval( $this->memberData['posts'] );
       $page           = ( $this->request['page'] > 1 ) ? ( ( $this->request['page'] - 1 ) * $limit ) : 0;

		//-----------------------------------------
   	// Grab articles new/recent in 1 bad ass query
   	//-----------------------------------------

		foreach( explode( ',', $this->settings['portal_latest_topics_forums'] ) as $forum_id )
		{
			if( !$forum_id )
			{
				continue;
			}

			$forums[] = intval($forum_id);
		}

	/* Loop through the forums and build a list of forums we're allowed access to */
	$forumIdsOk  = array();

	foreach( $this->registry->class_forums->forum_by_id as $id => $data )
	{
		/* Allowing this forum? */
		if ( count($forums) && !in_array( $id, $forums ) )
		{
			continue;
		}

		/* Can we read? */
		if ( ! $this->registry->permissions->check( 'read', $data ) )
		{
			continue;
		}

		/* Can read, but is it password protected, etc? */
		if ( ! $this->registry->class_forums->forumsCheckAccess( $id, 0, 'forum', array(), true ) )
		{
			continue;
		}

		if ( ! $data['can_view_others'] )
		{
			continue;
		}

		if ( $data['min_posts_view'] > $posts )
		{
			continue;
		}

		if ( $data['password'] != '' )
		{
			continue;
		}            

		$forumIdsOk[] = $id;
	}

	if( !count($forumIdsOk) )
	{
		return '';
	}

	//-----------------------------------------
	// Get topics
	//-----------------------------------------        

       # Setup our topic conditions
	$where_clause[]   = "t.forum_id IN (" . implode( ",", $forumIdsOk ) . ")";		
	$parseAttachments = false;
	$topics           = array();
	$topicCount       = 0;
       $defaultOrder     = ( $this->settings['portal_topics_order_by'] ) ? $this->settings['portal_topics_order_by'] : 'last_post';    

       # Skip pinned topics
       if( $this->settings['portal_exclude_pinned'] )
       {
           $where_clause[]   = "t.pinned=0";    
       } 

       # Topic sql query
	$this->DB->build( array( 
							'select'	=> 't.*',
							'from'		=> array( 'topics' => 't' ),
                               'order'     => "t.{$defaultOrder} DESC",
							'where'		=> "t.approved=1 AND t.state != 'link' AND " . implode( ' AND ', $where_clause ),
                               'limit'     => array( $page, $limit ),
							'add_join'	=> array(
												array( 
														'select'	=> 'p.*',
														'from'	=> array( 'posts' => 'p' ),
														'where'	=> 'p.pid=t.topic_firstpost',
														'type'	=> 'left'
													),
												array(
														'select'	=> 'f.id, f.name, f.name_seo, f.use_html',
														'from'		=> array( 'forums' => 'f' ),
														'where'		=> "f.id=t.forum_id",
														'type'		=> 'left',
													),
												array( 
														'select'	=> 'm.member_id, m.members_display_name, m.member_group_id, m.members_seo_name, m.mgroup_others, m.login_anonymous, m.last_visit, m.last_activity',
														'from'		=> array( 'members' => 'm' ),
														'where'		=> 'm.member_id=p.author_id',
														'type'		=> 'left'
													),
												array( 
														'select'	=> 'pp.*',
														'from'		=> array( 'profile_portal' => 'pp' ),
														'where'		=> 'pp.pp_member_id=m.member_id',
														'type'		=> 'left'
													),

												)
				)		);

	$outer = $this->DB->execute();

		while( $row = $this->DB->fetch( $outer ) )
		{ 			
			$bottom_string		= "";
			$read_more			= "";
			$top_string			= "";
			$got_these_attach	= 0;

		if( $row['topic_hasattach'] )
		{
			$parseAttachments = true;
		}

		//-----------------------------------------
		// Parse the post
		//-----------------------------------------

		IPSText::getTextClass( 'bbcode' )->parse_smilies			= $row['use_emo'];
		IPSText::getTextClass( 'bbcode' )->parse_html				= ( $row['use_html'] and $row['post_htmlstate'] ) ? 1 : 0;
		IPSText::getTextClass( 'bbcode' )->parse_nl2br				= $row['post_htmlstate'] == 2 ? 1 : 0;
		IPSText::getTextClass( 'bbcode' )->parse_bbcode				= 1;
		IPSText::getTextClass( 'bbcode' )->parsing_section			= 'topics';
		IPSText::getTextClass( 'bbcode' )->parsing_mgroup			= $row['member_group_id'];
		IPSText::getTextClass( 'bbcode' )->parsing_mgroup_others	= $row['mgroup_others'];
		$row['post']	= IPSText::getTextClass( 'bbcode' )->preDisplayParse( $row['post'] );

			//-----------------------------------------
			// BASIC INFO
			//-----------------------------------------

			$real_posts			= $row['posts'];
			$row['posts']		= ipsRegistry::getClass('class_localization')->formatNumber(intval($row['posts']));

           $row	= IPSMember::buildDisplayData( $row );

		# Attachments?			
		if( $row['pid'] )
		{
			$attach_pids[ $row['pid'] ] = $row['pid'];
		}
		if ( IPSMember::checkPermissions('download', $row['forum_id'] ) === FALSE )
		{
			$this->settings[ 'show_img_upload'] =  0;
		} 

           $row['share_links'] = IPSLib::shareLinks( $row['title'], array( 'url' => $this->registry->output->buildSEOUrl( 'showtopic=' . $row['tid'], 'publicNoSession', $row['title_seo'], 'showtopic' )  ) );

		$topics[] = $row;
	}

       # Pagination
       if( $this->settings['portal_topics_pagination'] )
       {
     		//$count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count', 'from' => 'topics', 'where' => "approved=1 AND state != 'link' AND " . str_replace( "t.", "", implode( ' AND ', $where_clause ) ) ) );

   		$pages = $this->registry->output->generatePagination( array( 'totalItems'		 => 25,
   																	 'itemsPerPage'		 => $limit,
   																	 'currentStartValue' => $page,
                                                                        'isPagesMode'		 => true,
                                                                        'seoTitle'			 => "app=portal",
                                                                        'seoTemplate'		 => "app=portal",
   																	 'baseUrl'			 => "app=portal",
   															)		);             
       }



		$output = $this->registry->getClass('output')->getTemplate('portal')->articles( $topics, $pages );

		//-----------------------------------------
		// Process Attachments
		//-----------------------------------------

		if ( $parseAttachments AND count( $attach_pids ) )
		{
		if ( ! is_object( $this->class_attach ) )
		{
			//-----------------------------------------
			// Grab render attach class
			//-----------------------------------------

			$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
			$this->class_attach                  = new $classToLoad( $this->registry );

			$this->class_attach->attach_post_key = '';

			ipsRegistry::getClass( 'class_localization' )->loadLanguageFile( array( 'public_topic' ), 'forums' );
		}

		$this->class_attach->attach_post_key	=  '';
		$this->class_attach->type				= 'post';
		$this->class_attach->init();

		$output = $this->class_attach->renderAttachments( $output, $attach_pids );
		$output	= $output[0]['html'];
		}

		return $output;
	}        

Рекомендованные сообщения

Опубликовано:

Связь между таблицей тем и сообщений есть только по первому посту темы.

 

'where' => 'p.pid=t.topic_firstpost',

Чтобы вывести последние сообщения нужны дополнительные костыли. Либо переписать запрос и сделать вложенный селект для отбора ид последних сообщений, либо по ид темы выбрать сначала ид сообщений потом указать их в основном селекте.

Но как вариант можете попробовать условие отбора по дате последнего сообщения темы:

'where' => 'p.pid=t.topic_firstpost',

заменить на

'where' => 'p.topic_id=t.tid AND p.post_date=t.last_post',

Опубликовано:
  • Автор

Спасиба, можна закрывать

Создайте аккаунт или войдите в него для комментирования

Сейчас на странице 0

  • Нет пользователей, просматривающих эту страницу.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.