Available on: Newsmag V1.8+, Newspaper V5+
The td_api_category_top_posts_style class allows you to add or modify the the top section which is present on category pages. The theme category template comes by default the with a Big Grid block on page top section which displays the first 5 posts from that category, using this class you can modify it. By default the theme uses Style 1 which looks like this:
The category top section style can be changed from the Theme Panel -> Categories. If you use the theme API to add a new category top section style it will appear like this:
The theme existing category top section styles are registered in td_config.php, the code looks like this:
td_api_category_top_posts_style::add('td_category_top_posts_style_1', array ( 'file' => TDC_PATH_LEGACY . '/includes/category_top_posts_styles/td_category_top_posts_style_1.php', 'posts_shown_in_the_loop' => 5, 'img' => TDC_URL_LEGACY . '/assets/images/panel/category_templates/icon-category-top-1.png', 'text' => 'Grid 1', 'td_block_name' => 'td_block_big_grid', 'group' => '' // '' - main theme, 'mob' - mobile theme, 'woo' - woo theme ) );
Parameters:
$id (string) (required)
- the category top section style id – if you add a new category top section style the id has to be different from the ones used on the other category top section styles which are registered in theme, if you plan to modify one of the existing category top section styles the id has to match with the one you’re planing to modify.
$params_array (array) (required)
- an array which contains the parameters of the category top section style:
Key name
|
Type
|
Description
|
---|---|---|
file | string | the path of the template file |
posts_shown_in_the_loop | integer | the number of posts displayed in the loop |
img | string | the icon path, it appears on Theme Panel -> Categories |
text | string | the title of the category top section style, it appears in Theme Panel -> Categories |
td_block_name | string | the block used on this section, by default it’s the Big Grid block |