Forums / National / Russian / Модули и плагины / [Plugin] Pagelist

1234>>>

Build customized page list widgets

Kort
#1 2012-11-14 16:18

[Plugin] Pagelist

Плагин вывода страниц через функцию по условиям (аргументам):

  • $tpl – имя шаблона
  • $items – количество выводимых элементов (при непустом $pagination – на страницу)
  • $order – сортировка в формате SQL (по умолчанию com_id DESC)
  • $extra – дополнительный SQL-запрос
  • $mode – режим (single, array_white, array_black, white, black)
  • $cats – разделы (строка, массив или строка с разделителями в виде ; (точка с запятой))
  • $subs – включать подразделы
  • $noself – исключить текущую страницу (если функция вызывается из шаблона страницы)
  • $offset -- сдвиг записей от начала (минус $offset первых страниц)
  • $pagination – код паджинации
  • $ajax_block – id блока при использовании аякса (включение аякса в конфиге плагина)
  • $cache_name – имя записи кэша
  • $cache_ttl – срок действия кэша

Примеры использования

// Вывести 5 последних страниц
{PHP|cot_pagelist(‘comlist’, 5}

// Вывести 5 последних страниц
{PHP|cot_pagelist(‘comlist’, 5, ‘page_date DESC’}

// Вывести 5 последних страниц суперадмина
{PHP|cot_pagelist(‘comlist’, 5, ‘page_date DESC’, ‘page_ownerid = 1’}

// Вывести 5 последних страниц раздела docs и его подразделов
{PHP|cot_pagelist(‘comlist’, 5, ‘page_date DESC’, ‘’, ‘single’, ‘docs’, ‘1’}

// Вывести 5 последних страниц, исключая разделы blog и system и их подразделы
{PHP|cot_pagelist(‘comlist’, 5, ‘page_date DESC’, ‘’, ‘black’, ‘blog;system’, ‘1’}

// Вывести 5 последних страниц из массива $some_array[] и их подразделов
{PHP.some_array|cot_pagelist(‘comlist’, 5, ‘page_date DESC’, ‘’, ‘array_white’, ‘$this’, ‘1’}

// Вывести страницы из массива $some_array[] и их подразделов с сортировкой по убыванию даты и разбивкой по 5 записей на страницу
{PHP.some_array|cot_pagelist(‘comlist’, 5, ‘page_date DESC’, ‘’, ‘array_white’, ‘$this’, ‘1’, 0, 0, ‘page’}

// Вывести страницы из массива $some_array[] и их подразделов с сортировкой по убыванию даты и разбивкой по 5 записей на страницу и ajax-паджинацией
{PHP.some_array|cot_pagelist(‘comlist’, 5, ‘page_date DESC’, ‘’, ‘array_white’, ‘$this’, ‘1’, 0, 0, ‘page’, ‘page2list’}

// Вывести 5 последних страниц, исключая разделы blog и system и их подразделы и закэшировать результат на 24 часа
{PHP|cot_pagelist(‘comlist’, 5, ‘page_date DESC’, ‘’, ‘black’, ‘blog;system’, ‘1’, 0, 0, ‘’, ‘’, ‘pagelist_blacklist’, 86400}

Страница загрузкиРепозиторий на Github

SED.by - создание сайтов, разработка плагинов и тем для Котонти
This post was edited by Kort (2023-09-08 13:23, 6 months ago)
Trustmaster
#2 2012-11-14 16:53

1) already implemented, download the latest version.

2) I doubt it's worth the effort. It is heavy on SQL and rarely really needed.

3) this is a good idea, you can add it to plugin issues directly on Github.

Thanks for feedback!

May the Source be with you!
Uch
#3 2012-11-14 18:00

Do you plan to make something like PageList for Forums posts? May be PostsList?

Trustmaster
#4 2012-11-14 20:03

Currently not.

May the Source be with you!
Uch
#5 2012-11-16 19:50

Приделал кэш. Скорость загрузки индекса выросла почти в три раза!

Macik
#6 2012-11-16 21:32

Can you share this version with others?

https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F
Uch
#7 2012-11-17 07:01

It does not make sense, because i just want to see how it speeds up index page loading. And i have made a little improvement to use Cotonti chache system excluding possible pagination and cache cleaning (for page add and page edit events). So this is just an experiment.

I pass a unique name of the variable containing the cache to the function, along with other parameters from TPL file.

Now i have to make it sensitive to the pagination system. And i have to think how to clean the cache when new page is added or some page is deleted, given that cache variable has a unique name.

And i have a main reason not to do it. I'm waiting for the official version of the plugin, knowing that the developers will make it better than me.

 

Wadik
#8 2013-06-09 15:38

А кеширование к этому чудному плагину так и не приделали?

foxhound
#9 2013-11-29 11:36

I think this is great and i am using it on some parts of my new website already.
But, I would appreciate a little help if anyone can. I would like to have a condition so it only outputs pages within a specific time frame, say 1 month. I have no idea how to make such a condition.
And, what would be the condition if you would for example want to output random pages from within a certain category.

I hope someone knows how to do this and can share his knowledge with me :)

There is one example condition on the page here which is pretty logical if you see it ( "page_count != "0" ) but to be honest I have no idea how to adjust such so the condition is set for a specific time from or for a random page in a category.

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Kort
#10 2013-11-29 13:36

1. You can use UNIX_TIMESTAMP() as current time value and play with it (i.e. compare to a page extrafield and check the difference).

2. You can use RAND() as sorting parameter to get randomly selected pages

SED.by - создание сайтов, разработка плагинов и тем для Котонти
foxhound
#11 2013-11-29 16:04

Thanks Kort, with that I can make some tries :)

Added 2 months later:

Anyone here knows how I could list only pages from the same page_owner as the ones whos page you are viewing?
Or in other words, output more pages from the same page_owner?

I tried to add a condition like:

page_author = "user_name"

but that gives 0 output. I added numerous variations of that and none work (so the list stays empty) or it gives me an sql error.
I also tried with page_owner but any attempt fails.

I hope someone can again give me some pointers :)

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
This post was edited by foxhound (2014-01-16 14:39, 10 years ago)
Twiebie
#12 2014-01-16 15:31

If you want to filter by page_author you could do it like this:

{PHP.pag.page_author|pagelist('pagelist.blog','8','page_date DESC','page_author = "$this"','','system;archives','','TRUE')}

You could also filter by page_ownerid with the user_id if the author is always the owner, which might prove to be a little bit more consistent as the page_author field might not always be set:

{PHP.pag.page_ownerid|pagelist('pagelist.blog','8','page_date DESC','page_ownerid = $this','','system;archives','','TRUE')}
Kort
#13 2014-01-16 15:48

Try smth like this:

{PAGE_OWNERID|pagelist('pagelist.hits','3','RAND()','page_ownerid = $this','','news;system','','TRUE')}


 

SED.by - создание сайтов, разработка плагинов и тем для Котонти
foxhound
#14 2014-01-16 17:52

Wow, thank you both very much! That has been very helpfull.
I decided to use Kort's approach as he used the available tag and I read if thats available it is adviced to use that instead of a php global. But I really appreciate you both posted different approaches.

And, just to show I am not only asking questions I used this plugin to output random newspages (20 items) from the last 3 months, except the current page like this: 

{PHP|pagelist('pagelist.random_news',20,'RAND()','UNIX_TIMESTAMP() < (page_date + 7889231)','news','','','TRUE','','TRUE')}

 

And this gives you all most read pages from the last month of a certain category (and sub categories) (10 items per page): 

{PHP|pagelist('pagelist.popular_news',10,'page_count DESC','UNIX_TIMESTAMP() < (page_date + 2629743)','mycat','','','true','','FALSE')}

I know most of you wont have any use for it, but maybe it helps someone like me someday ;)

 

Added 17 hours later:

Is it possible to also make this work with comments? I tried things like this: 

{PAGE_ROW_COMMENTS_COUNT|pagelist('pagelist.authorpage','5','$this DESC','','news','','','TRUE','','')}

But it keeps giving sql errors.
I also tried to add a condition to only list when "$this > 0" but it seems its ignoring anything.
 

I also tried this plugin: http://www.cotonti.com/extensions/navigation-structure/581 but it seems to no longer work.
I guess/fear the pagelist plugin can not create any output based on comments as comments are just an additional plugin?

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
This post was edited by foxhound (2014-01-17 10:54, 10 years ago)
Kort
#15 2014-01-17 11:45

You're right. Pagelist can only generate a link to and a number of comments for each page entry (if the corresponding option is enabled in the plugin config).

SED.by - создание сайтов, разработка плагинов и тем для Котонти

1234>>>