Latte - Counter Badge

For support and discussion related to templates, themes, and imagesets in phpBB 3.2.
Post Reply
User avatar
Neverlands
Registered User
Posts: 57
Joined: Thu Sep 05, 2002 12:06 am
Location: Vienna / Austria
Contact:

Latte - Counter Badge

Post by Neverlands » Fri Jun 28, 2019 4:11 pm

Hello,

I use the "Latte" theme but I guess the question I have is more or less a general one.
I want to display a counter badge for the navigation tab called "Auktionen" which looks similar to Latte's private messages counter:

Image

I load the figure for the counter (".bubble" span) from a sub page into the ".counter.auction-count" span of the navbar_header.html:

Template navbar_header.html:

Code: Select all

<!-- DEFINE $AUCTION_COUNT -->
<script> 
	$(function (){
	  $(".auction-count").load("/eqdkp_plus/Guildbank.html .bubble");
	});
</script>
<!-- ENDDEFINE -->

Code: Select all

<li class="tab auktionen responsive-hide<!-- IF $AUCTION_COUNT > 0 --> non-zero<!-- ENDIF --> data-responsive-class="small-icon icon-gavel" data-select-match="auktionen">
	<a class="nav-link" href="/auktionen">Auktionen</a>
	<strong>
		<span class="counter auction-count">{$AUCTION_COUNT}</span>
		<span class="arrow"></span>
	</strong>
</li>
HTML result navbar_header.html:

Code: Select all

<li class="tab auktionen responsive-hide non-zero data-responsive-class= responsive-cloned-item" small-icon="" icon-gavel"="" data-select-match="auktionen" title="Auktionen" data-clone-index="4">
	<a class="nav-link" href="/auktionen">Auktionen</a>
	<strong>
		<span class="counter auction-count"><span class="bubble">0</span></span>
		<span class="arrow"></span>
	</strong>
</li>
So far so good. But unfortunately the <!-- IF $AUCTION_COUNT > 0 --> non-zero<!-- ENDIF --> doesn't work. "0" from <span class="bubble">0</span> is not recognized. So the counter is always displayed also, if its figure = 0. Propably I need to load just the figure/text /content of the span ".bubble" into the "counter.auction-count" span so it would look like this, but I don't know how to do it:

<span class="counter auction-count">0/span>

I have also tried it to do it all via overall_header.html without a phpBB variable. But "0" or - any other figure - is not recognized:

Template overall_header.html

Code: Select all

<script> 
	$(function (){
		$(".auction-count").load("/eqdkp_plus/Guildbank.html .bubble");
	});
</script>

<script>
$( document ).ready(function() {
  var value = (document.getElementsByClassName("bubble").innerHTML === "0");
     if(!value) { 
      $('li.auktionen').removeAttr("title");
      } else {
         $('li.auktionen > strong').remove();
         $('li.auktionen').removeClass('non-zero').removeAttr("title");
   }
});
</script>

I am not a professionalist and don't have any clue what else I could try.
Help is very appreciated :)

Post Reply

Return to “[3.2.x] Styles Support & Discussion”