view numbers in block

Posted in: Newspaper
Post count: 2

Hello

How can I show view numbers in block_9

I choose most read in filter and want to show how many reads

thanks in advance

Post count: 3343

Hi,

You need to make a modification to show the views.

1. Add <?php echo $this->get_views(); ?> in td_module_9.php like here: http://screencast.com/t/koCkDeey

2. Copy the function get_views() from td_module_single_base.php in td_module.php like here: http://screencast.com/t/6pDj3N6S

3. Used this CSS for a better alignment, add it in Theme Panel -> Custom CSS section

.td_module_wrap .td-module-meta-info .td-post-views {
position: relative;
display: inline-block;
top: 2px;
margin-left: 14px;
color: #aaa;
}

.td_module_wrap .td-module-meta-info .td-post-views span {
margin-left: 5px;
}

Result: http://screencast.com/t/bxe0fSQep5

Thanks for the message!

Post count: 2

absolutely perfect 😛

Post count: 1341

Hi!

Please tell me where is the files

td_module_single_base.php and td_module.php?

/Newspaper/includes/wp_booster

Right?

And if I use a child theme, then after editing, these files should be located

/Newspaper-child/includes/wp_booster

  • This reply was modified 10 years by Edward.
Post count: 1341

In what place of file td_module_single_base.php

function get_views() {
$buffy = '';
if (td_util::get_option('tds_p_show_views') != 'hide') {
$buffy .= '<div class="td-post-views">';
$buffy .= '<i class="td-icon-views"></i>';
// WP-Post Views Counter
if (function_exists('the_views')) {
$post_views = the_views(false);
$buffy .= $post_views;
}
// Default Theme Views Counter
else {
$buffy .= '<span class="td-nr-views-' . $this->post->ID . '">' . td_page_views::get_page_views($this->post->ID) .'</span>';
}

$buffy .= '</div>';
}
return $buffy;
}

should I insert in file td_module.php?

Post count: 22421

Hello,

You will need to copy the code from td_module_single_base.php and paste it in td_module.php and place it somewhere it does not affect other code, like for example here: http://screencast.com/t/CafGhKBymhz,
Then you need to edit td_module_8.php and add the line like in this screenshot: http://screencast.com/t/koCkDeey
<?php echo $this->get_views(); ?>
You can then use the css from above in the theme panel->custom css box for positioning.

I hope this helps!
Thanks.

Post count: 1341

Hi Bogdan!
Thanks for answer.

If I use a child-theme then after editing file td_module.php should be located

/Newspaper-child/includes/wp_booster?

Post count: 22421

Hi,
You need to keep the path as the original under the child theme. So, yes it should be in /Newspaper-child/includes/wp_booster
Thanks.

Post count: 1341

I asked why so much detail: does not work.

Fatal error: Call to undefined method td_module_6::get_views() in /home/MySite/public_html/wp-content/themes/Newspaper-child/includes/modules/td_module_6.php on line 24

Line 24:
<?php echo $this->get_views();?>

Post count: 22421

Hello,

Please try to make these modifications to the main files so you can check to see if the modification worked as expected. And copy over the files in the child theme. Do a back-up of these files before you modify them. If the modification that works in the main file does not work from the child theme, then certain files will not be manageable from the child theme. I think the wp_booster files cannot be managed by the child theme.
Here is a list of files that can be used with the child theme: https://forum.tagdiv.com/the-child-theme-support-tutorial/

Thanks.

Post count: 1341

Yes. And so it was: wp_booster files cannot be managed by the child theme.

Future platform support wp_booster files in child theme?

Or will show the view numbers on the home page in future versions of the theme?

Thanks!

Post count: 22421

Hello,

We try to improve our theme on every update, including the child theme support as stated here: http://screencast.com/t/utFewXhfcm
As for the views i will add them to our list of updateds and hopefully in a future version we will be able to implement views on all blocks.

Thank you!

Post count: 1341

Thank you! Then let’s not hurry with the modifications.

Post count: 2

Hello,

I have done all three steps above but without any result.

I use block 11 so I modified file td_module_11.php ofcourse.

Is this procedure valid also for block 11?

Thanks a lot in advance for your help.

Post count: 22421

Hi,
A module is not the same as a block. The module is the base element and a block is simply a container for modules. Block 11 does not use module 11. You can see a list of what modules are used on what blocks here: http://screencast.com/t/95I3JzMoIZ
Please apply the modification in module 10 as this is the module used in block 11
Thank you!

Post count: 2

Hello Bogdan,

thank you very much for your help. Everything works.
I did not realize which module should be modified – so sorry for the stupid question.
Have a nice day.

Viewing 16 posts - 1 through 16 (of 16 total)
The forum ‘Newspaper’ is closed to new topics and replies.