-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stats widget #18
Comments
To help with this scenario the theme comes with a little script that runs on all pages. example usage: https://github.com/gbif/hp-colombian-biodiversity/blob/master/_data/home.yml |
Thanks this is helpful. However, I was wondering how to automatically use the predicates of our portal here. In the case of the Colombian example, they seem to count everything that is published by columbia (i.e. "publishing_country=CO"), but we would like to count only those datasets and occurences that we included in our portal. Is there a way to directly draw this information from our portal configuration? |
https://github.com/gbif/hp-colombian-biodiversity/blob/master/_data/home.yml#L7 in this line they do a graphql query. It isn't automatically taken from their site configuration though. They explicitly added what query they wanted to make. So in your case the number of occurrences is this graphql query given your current filter The attribute and for images only you would have to extend the search predicate with |
Thanks, Morten! |
Hi - I can see how it is a but cumbersome for you as your scope is a long list of datasets. It isn't something I have implemented. But you can implement it. It is a Jekyll site with a theme and you control it completely. You can add your own script and a shared variable with the list of datasets. I added a little script as part of the theme to make it simple to show counts. If it is awkward in your case, then it is perfectly reasonable to write a script that fits your needs better. It could be done with a custom javascript function or by putting the list of dataset keys in a Liquid variable. |
Thanks for the response. It sounds like that would be a good solution. Unfortunately, I'm not a developer and I have no idea how to do this. Is there any chance you could help us with this? |
Here is a very simple solution - title: |
<span id="datasetCount">10</span>
<script>
document.getElementById('datasetCount').innerHTML = siteConfig.occurrence.rootPredicate.predicates[0].values.length;
</script>
description: Datensätze
background: /assets/icons/datasets.png
href: /occurrence/search/?view=DATASETS It isn't perfect in that it has assumptions, but for what you nede it is probably fine. Assumptions
|
I think there is no way to convert our filter to a simple GET call, which (as far as I see) is need for that. |
You can make graphql queries with GET as in the example above and now below. So unless your list of datasets grow a lot the size of that won't be an issue. But using a network will be simpler for you. But it is also possible to do it with the current setup
|
Thanks Morten... I missed that GraphQL query. |
that is decided by the requested content type. In your case the simplest is probably just to write a small script that gets the needed counts and updates some named tags you know exists. That said, I can see how this is so generic that adding something on theme level could make sense. Not everyone likes writting javascript. And even those that know how to do not always like it. the most tricky part is to know what endpoint to use (dev/uat/staging/prod) - which is a variable we inject at build time into the _config.yml if not already defined. let me check that part. But even if hardcoded to staging it wouldn't be an issue for you and the end users |
I think this should do it. I'll look into something on a theme level. Just not sure how to make it general enough to be useful update: Available in staging now |
Wow - that was quick. I wonder what you can do after the second coffee! |
In that case it was the right distribution of skills. It simply replace content if an element has one of these ids |
Dear @MortenHofft,
could you please help us with the stats widget on the homepage? We would like to show the number of occurrences, number of datasets and number of occurrences with photos.
So far, I was only able to hardcode the values here:
hp-land/_data/home.yml
Line 67 in 6f40939
Could you help us so it updates automatically? I'm not very familiar with the API..
Thnak you very much!
The text was updated successfully, but these errors were encountered: