Skip to content

Листинг и фильтр для Links на главной

В приложение Links можно выводить записи на главную страницу приложения (affiliates). Вывел все записи.

Однако если записей очень много, то главная страница становиться очень большая. Не подскажите как сделать листинг таких записей на главной странице (как в категориях, там листинг есть).

 

И ещё можно ли сделать фильтр для записей на главной странице, наподобие того что есть в категориях?

Featured Replies

  • Author

В приложение Links можно выводить записи на главную страницу приложения (affiliates). Вывел все записи.

Однако если записей очень много, то главная страница становиться очень большая. Не подскажите как сделать листинг таких записей на главной странице (как в категориях, там листинг есть).

Я так понял что нужно видимо в файле categories.php вот это:

 

		/* Figure out pagination */
	$totalLinks = $this->DB->buildAndFetch( array(	'select'		=>	'COUNT( link_id ) AS totalLinks',
																									'from'			=>	'links g',
																									'where'			=>	'link_category_id = ' . $category[ 'category_id' ] . $sqlLinkOpen . $sqlTimeBetween ) );

	$totalLinks = $totalLinks[ 'totalLinks' ];

	$category[ 'pagination' ] = $this->registry->output->generatePagination(	array(	'totalItems'        => $totalLinks,
																																										'itemsPerPage'      => $perPage,
																																										'currentStartValue' => $startVal,
																																										'seoTitle'					=> $category[ 'category_seo_title' ],
																																										'seoTemplate'				=> 'showlinkcat',
																																										'baseUrl'           => 'app=links&showlinkcat=' . $category[ 'category_id' ] ) );

 

 

Подключить к блоку affiliates:

 

		/* Get us some affiliates */
	$affData = false;
	if ( $this->settings[ 'g_show_affiliates' ] == 1 )
	{
		$this->DB->build(	array(	'select'		=>	'*',
															'from'			=>	'links',
															'where'			=>	'link_approved = 1',
															'limit'			=>	array( 0, 50 ),
															'order'			=>	'link_last_post_date DESC' ) );
		$affiliates = $this->DB->execute();

		$affData = array();
		while ( $row = $this->DB->fetch( $affiliates ) )
		{
			$row = $this->links->parseGink( $row );			
			$affData[ $row[ 'link_id' ] ] = $row;
		}
	}

 

 

 

		$affData = false;
	if ( $this->settings[ 'l_show_affiliates' ] == 1 )
	{
		$start = ( isset( $this->request[ 'st' ] ) && $this->request[ 'st' ] > 0 ) ? intval( $this->request[ 'st' ] ) : 0;

		$perPage = 25;

		$this->DB->build( array(
			'select' 	=>	'*',
			'from'		=>	'links',
			'where'		=>	'link_approved = 1 AND link_affiliate = 1',
               'limit'	=>  array( $start, $perPage ),
			'order'		=>	'link_added DESC',
			'calcRows'	=>	true,
		) );

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

		$total = $this->DB->fetchCalculatedRows();

		$affData = array();
		while ( $row = $this->DB->fetch( $affiliates ) )
		{
			$row = $this->links->parseLink( $row );			
			$affData['links'][ $row[ 'link_id' ] ] = $row;
		}

		$affData['pagination'] = $this->registry->output->generatePagination( array(
			'totalItems'		=> $total,
			'itemsPerPage'      => $perPage,
			'currentStartValue' => $start,
			'seoTitle'			=> '',
			'seoTemplate'		=> 'app=links',
			'baseUrl'           => 'app=links'
		) );			
	}

 

 

И в шаблоне заменить

			<if test="is_array( $affiliates ) AND count( $affiliates )">
			{parse striping="linksTable" classes="row1,row2"}
			<foreach loop="$affiliates as $affId => $affiliate">

на

			<if test="is_array( $affiliates['links'] ) AND count( $affiliates['links'] )">
			{parse striping="linksTable" classes="row1,row2"}
			<foreach loop="$affiliates['links'] as $affId => $affiliate">

 

Пагинация

		<if test="$affiliates['pagination']">
		<div class='topic_controls'>
			{$affiliates['pagination']}
		</div>
	</if>

  • Author

@newbie,

Спасибо большое!

 

А как теперь страницам задать тег каноникал?

А как теперь страницам задать тег каноникал?

 

$this->registry->getClass('output')->addCanonicalTag( ( $this->request['st'] ) ? 'app=links' . '&st=' . $this->request['st'] : 'app=links', '', 'app=links' );

  • Author

@newbie,

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

 

А подключение фильтра к affiliates никак не возможно?

А подключение фильтра к affiliates никак не возможно?

Посмотрите фильтры категории и сделайте аналогично.

  • Author

Посмотрите фильтры категории и сделайте аналогично.

Изначально так и сделал. Взял с шаблона categoryView часть кода отвечающего за фильтр и скопировал его в шаблон linksSystemHome:

 

 

<div id='forum_filter' class='filter_bar rounded'><span id='show_filters' class='clickable' style='display: none'>{$this->lang->words[ 'filter_options' ]}</span><form id='filter_form' action='{parse url="showlinkcat={$cat[ 'category_id' ]}&st={$this->request[ 'st' ]}" template="showlinkcat" seotitle="{$cat[ 'category_seo_title' ]}" base="publicWithApp"}' method="post"><fieldset><label for='sort_by'>{$this->lang->words[ 'filter_sort_by' ]}</label> <select name="sortBy" id='sort_by' class='input_select'>{$cat[ 'footer_filters' ][ 'sortBy' ]}</select><label for='direction'>Направление</label> <select name="sortDirection" id='direction' class='input_select'>{$cat[ 'footer_filters' ][ 'sortDirection' ]}</select><label for='time_frame'>{$this->lang->words[ 'filter_time_frame' ]}</label> <select name="sortTime" id='time_frame' class='input_select'>{$cat[ 'footer_filters' ][ 'sortTime' ]}</select><input type='checkbox' value='1' name='rememberSort' class='input_check' id='remember_filter' /> <label for='remember_filter'>Запомнить</label> <input type="submit" value="Ок" class="input_submit alt" /></fieldset></form></div>

 

Эффекта никакого.

Create an account or sign in to comment

Account

Navigation

Search

Search

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.