Jump to content

Real Numbers instead of Friendly Number Format


Go to solution Solved by MLS,

Recommended Posts

We are a fan fiction community where the writers want to know the actual number of views, so instead of 12.3K they would like it to see 12,345.   How does one change back to actual view numbers instead of the friendly number format?   

We are on version 4.7.11.1 

I'm not a programmer just a volunteer novice, so any help is appreciated.

Link to comment
Share on other sites

I fixed this for my community by editing the CSS for my default and night themes. The difference between full and short number is the little line inside the class which contains number, and that line affects the format of the number:

 

 format="short"

 

The tricky part is to find where exactly the number you want to fix "lives" in the code.

I did it for numbers in Forum Statistics sidebar block which seen on main forum and for the number of posts (and reputation which I added myself) which seen under the avatar when you read a topic.

 

So, let's assume for an example you want to fix the number of posts in Forum Statistics, your forum is not in English and you are using Firefox browser. Left mouse click on the number of posts, select Inspect Element. You'll see the developer tool and lines of code which will look like: <div class><div class><li class>blah-blah-blah</li></div></div>

One line will be selected, it will look like: <span class="ipsDataItem_stats_number">4.7K</span> - this is where the number lives, but you need to know the name of the block (actually you can use it for search as well, but I'll explain later).

Slowly scroll up reading lines until you see the long paragraph with data-blocktitle="blah-blah-blah". Between quotes you will see the name of the block in your language pack. Remember it, then go to AdminCP -> Customization -> Languages -> [your default language] -> Translate  -> Search settings -> [type the block name into the third input field, which is your language] -> Search.

If you did it right, you'll see in the Key column there is block_forumStatistics , so the name of the block is forumStatistics , copy it. Then go to AdminCP -> Customization -> Themes -> [your default theme] -> Edit HTML & CSS, then paste forumStatistics into search field, and click on found results until you can see and click on forumStatistics (the path is: forums -> front  -> widgets  -> forumStatistics ).

 

Now you see the code of the block! Can you spot that "unfriendly" format="short" line?

 

<h3 class='ipsType_reset ipsWidget_title'>{lang="block_forumStatistics"}</h3>
<div class='ipsWidget_inner'>
	{{if $orientation == 'vertical'}}
		<div class='ipsPad_half'>
			<ul class='ipsDataList'>
				<li class='ipsDataItem'>
					<div class='ipsDataItem_main ipsPos_middle'>
						<strong>{lang="total_topics"}</strong>
					</div>
					<div class='ipsDataItem_stats ipsDataItem_statsLarge'>
						<span class='ipsDataItem_stats_number'>{number="$stats['total_topics']" format="short"}</span>
					</div>
				</li>
				<li class='ipsDataItem'>
					<div class='ipsDataItem_main ipsPos_middle'>
						<strong>{lang="total_posts"}</strong>
					</div>
					<div class='ipsDataItem_stats ipsDataItem_statsLarge'>
						<span class='ipsDataItem_stats_number'>{number="$stats['total_posts']" format="short"}</span>
					</div>
				</li>
			</ul>
		</div>
	{{else}}
		<div class='ipsGrid ipsGrid_collapsePhone ipsWidget_stats'>
			<div class='ipsGrid_span6 ipsType_center'>
				<span class='ipsType_large ipsWidget_statsCount'>{number="$stats['total_topics']" format="short"}</span><br>
				<span class='ipsType_light ipsType_medium'>{lang="total_topics"}</span>
			</div>
			<div class='ipsGrid_span6 ipsType_center'>
				<span class='ipsType_large ipsWidget_statsCount'>{number="$stats['total_posts']" format="short"}</span><br>
				<span class='ipsType_light ipsType_medium'>{lang="total_posts"}</span>
			</div>
		</div>
	{{endif}}
</div>

 

Just delete that format attribute, but be careful not to erase any { } brackets, or you will break the code and there will be bugs on your forum. Also please notice, that the block is divided by if and else on two halves - one is the code for desktop users, the other is for mobile users. The post number exists in both versions, so you need to edit both. I specifically chose Forum Statistics block for an example, because it's code is really short and neat. But when you will fix other blocks, the code will be much longer, and when you'll find your only line with short format you will think this is it. Nope, there's always another one somewhere below, don't forget to edit it too!

 

The result should look like this, please compare:

<h3 class='ipsType_reset ipsWidget_title'>{lang="block_forumStatistics"}</h3>
<div class='ipsWidget_inner'>
	{{if $orientation == 'vertical'}}
		<div class='ipsPad_half'>
			<ul class='ipsDataList'>
				<li class='ipsDataItem'>
					<div class='ipsDataItem_main ipsPos_middle'>
						<strong>{lang="total_topics"}</strong>
					</div>
					<div class='ipsDataItem_stats ipsDataItem_statsLarge'>
						<span class='ipsDataItem_stats_number'>{number="$stats['total_topics']"}</span>
					</div>
				</li>
				<li class='ipsDataItem'>
					<div class='ipsDataItem_main ipsPos_middle'>
						<strong>{lang="total_posts"}</strong>
					</div>
					<div class='ipsDataItem_stats ipsDataItem_statsLarge'>
						<span class='ipsDataItem_stats_number'>{number="$stats['total_posts']"}</span>
					</div>
				</li>
			</ul>
		</div>
	{{else}}
		<div class='ipsGrid ipsGrid_collapsePhone ipsWidget_stats'>
			<div class='ipsGrid_span6 ipsType_center'>
				<span class='ipsType_large ipsWidget_statsCount'>{number="$stats['total_topics']" format="short"}</span><br>
				<span class='ipsType_light ipsType_medium'>{lang="total_topics"}</span>
			</div>
			<div class='ipsGrid_span6 ipsType_center'>
				<span class='ipsType_large ipsWidget_statsCount'>{number="$stats['total_posts']" format="short"}</span><br>
				<span class='ipsType_light ipsType_medium'>{lang="total_posts"}</span>
			</div>
		</div>
	{{endif}}
</div>

 

Also you could use ipsDataItem_stats_number instead of forumStatistics for search, but in this is case you will get as the results all the blocks where the number is used, and you might not want to change all of them.

 

Another example is number of posts under the avatar. I don't even remember how I found it in the code, I guess I just clicked on all the templates where I thought it might hide. Turned out, it's on the block called postContainer (the path is: forums -> front  -> topics  -> postContainer ).

The code is really long, so I just show the tiny bit:

<div class='cAuthorPane_content'>
			<h3 class='ipsType_sectionHead cAuthorPane_author ipsType_break ipsType_blendLinks ipsFlex ipsFlex-ai:center'>
				{template="userLink" group="global" app="core" params="$comment->author(), $comment->warningRef(), TRUE, $comment->isAnonymous()"}
			</h3>
            {{if $comment->author()->member_id}}
				<a href="{url="app=core&module=members&controller=profile&id={$comment->author()->member_id}&do=content" seoTemplate="profile_content" seoTitle="$comment->author()->members_seo_name"}" title="{lang="member_post_count" pluralize="$comment->author()->member_posts"}" data-ipsTooltip class="ipsType_blendLinks">
					<i class="fa fa-comment"></i> {number="$comment->author()->member_posts" format="short"}
				</a>
			{{endif}}

 

I removed short format and added reputation as well:

 

<div class='cAuthorPane_content'>
			<h3 class='ipsType_sectionHead cAuthorPane_author ipsType_break ipsType_blendLinks ipsFlex ipsFlex-ai:center'>
				{template="userLink" group="global" app="core" params="$comment->author(), $comment->warningRef(), TRUE, $comment->isAnonymous()"}
			</h3>
            {{if $comment->author()->member_id}}
				&nbsp;
          		<a href="{url="app=core&module=members&controller=profile&id={$comment->author()->member_id}&do=content" seoTemplate="profile_content" seoTitle="$comment->author()->members_seo_name"}" title="{lang="received_x_points" pluralize="$comment->author()->pp_reputation_points"}" data-ipsTooltip class="ipsType_semiBold ipsType_success">
					<i class="fa fa-plus-circle"></i> {number="$comment->author()->pp_reputation_points"}
				</a>
          		&nbsp;
				<a href="{url="app=core&module=members&controller=profile&id={$comment->author()->member_id}&do=content" seoTemplate="profile_content" seoTitle="$comment->author()->members_seo_name"}" title="{lang="member_post_count" pluralize="$comment->author()->member_posts"}" data-ipsTooltip class="ipsType_blendLinks">
					<i class="fa fa-comment"></i> {number="$comment->author()->member_posts"}
				</a>
			{{endif}}

 

Same logic for a different class below in the code.

 

You can do it with any numbers, but you had to read the code to understand what you are changing right now.

 

I hope this helps.

Link to comment
Share on other sites

This is very helpful!   

I wondered why I should have to pay for a plug in for "actual numbers" when I know the software is counting views.   

There should be a control in AdminCP on how we want the numbers displayed, modern friendly or the exact actual numbers.    

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...