A-Z Listings and no results for a letter


(Mahearnpad) #1

Matrix Version:
5.3.2.1

I want to have the letter (button) be disabled when there are no results for that letter. I thought that this behaviour was built into the asset listing asset. But I can’t find it anywhere.

Failing that, I can’t see how it could be done (using JS), because it would need to be done internally when the page loads.

I forgot to add that also, currently when a letter is clicked on that doesn’t have any results for it, the behaviour is that the listing shows the results for “A”. I’ve done some testing, and any request for the page without the query parameters, or where no value is passed, produces a results as if “A” was requested.

Any ideas?


(Anthony Ponomarenko) #2

Hey there,

Im assuming you have a multiple page A-Z listing, using the %page_list% in the Page Contents of the Asset Listing? If so the default behaviour is to not have a link on the Letters that are empty.

Can you provide more details of your implementation, perhaps a screen shot or two. Even the listing exported as xml that i could import to check it out


(Mahearnpad) #3

Hi Anthony

My A-Z list is like this:

<ul class="index">
	<li><a class="key a" href="/policy_library/policy_instruments_a-z?result_225308_result_page=A">A</a></li>
	<li><a class="key b" href="/policy_library/policy_instruments_a-z?result_225308_result_page=B">B</a></li>
	<li><a class="key c" href="/policy_library/policy_instruments_a-z?result_225308_result_page=C">C</a></li>
	<li><a class="key d" href="/policy_library/policy_instruments_a-z?result_225308_result_page=D">D</a></li>

On the page contents of the asset lister, I’m doing this:

<div>
    <h2>&#%page_number^add:64%;</h2>
    <ul class="document-listing">
       %asset_listing%
    </ul><!-- /document-listing -->
</div>

Note I’m not use the %page_list% keyword, because I’m using my own key list. Do you think that I should use the %page_list%? Then how to customise it the way I want it, like so:

Thanks


(Anthony Ponomarenko) #4

I would suggest using %page_list% as the functionality you want is built in.
In the Details page of the listing there is the ‘A-Z Letter Format’ which allows you to provide the html tag code for the letters; you can just add the css class names there to use the same styles you currently have.


(Mahearnpad) #5

Ok, thanks. I’ll give that that a go.

BUT, I notice that my code to show the current letter as the heading for the results:

<h2>&#%page_number^add:64%;</h2> is not working. It’s not working because it seems that any letters that do not contain a result set, are not counted as a page. Therefore I cannot rely on adding 64 to the page number, to get the ascii character of the relevant letter. I thought I had a good solution for this, but alas no.

How would I be able to achieve the heading?

thanks for your help! :smiley:


(Mahearnpad) #6

Anthony, I’ve been able to everything using the built-in functionality. I have it looking the way I want it.

However, I still have no way of getting the heading for the top of result list.

Notice that %page_number% on the iterator is actually the letter, but on the result page bodycopy, it’s the actual number. This is very frustrating, because if number 11 = L (if K is missing), then if I want to use that to get the letter, when I add 64 (using the method described earlier, the actual letter for L, is K.

I may have to remove the heading letter, as I can’t find a way to do it. But I’m sure people do this all the time - what is the way?

thanks
Michael


(Peter McLeod) #7

Hi

Can you just grab the letter from the query string?

`%globals_get_result_225308_result_page%

Thanks
Peter


(Mahearnpad) #8

Thank you Peter. That’s it!