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

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

Recommended Posts

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

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

 

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

Share this post


Link to post

В приложение 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;
		}
	}

 

 

Share this post


Link to post

 

		$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>

  • Upvote 1

Share this post


Link to post

@newbie,

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

 

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

Share this post


Link to post

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

 

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

  • Upvote 1

Share this post


Link to post

@newbie,

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

 

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

Share this post


Link to post

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

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

Share this post


Link to post

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

Изначально так и сделал. Взял с шаблона 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>

 

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

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...