Hide/Show Angular via URL Variables

flickr photo shared by Internet Archive Book Images with no copyright restriction (Flickr Commons) For some reason I’ve been hiding/showing things a lot recently. One nice little trick I saw (and have already used) was based on the target class. You can see it working – hidden here and expanded here. Notice the #details piece in the URL. The CSS that makes it work is below. Nice and simple. That’s nice if it’s one element you can address via an id. It doesn’t work if you want to hide and show multiple items which might have the same id. I wandered around a bit and found a more interesting way to do it in Angular. The following javascript gets the variable from the URL. It’s straight from this article. So this URL http://bionicteaching.com/tools/hcps/hcps-tools.html?school=varina_hs would pass varina_hs to the variable school. If the school=varina_hs chunk is gone, then the box is invisible. I need to add that variable to the Angular scope so it can be accessed in the template. So now that we have that we can use it. Wandering around a bit I found ng-if. It’s essentially a way to show or hide and element based on whether the statement returns true. This code will return TRUE under either of two conditions. If the JSON element entry.gsx$school.$t has the […]

Benson, Discourse, and WordPress

It sounds like an exciting new buddy movie . . . but it’s an attempt to better integrate elements of our Discourse install in WordPress using Benson (a neat plugin Mark made that lets you use Angular w/in WordPress). I decided to look into this after seeing this example using Twig. Ordinarily, I’d do something like this using Discourse’s RSS feeds and probably manipulating it with FacetWP. I’m opting to look at these other options for a few reasons. One, with WordPress expanding JSON I want a better idea of how all that works in comparison to RSS. Two, I don’t really like duplicating all this content through the syndication option if I can achieve the same effect in other ways. I’m not so worried about space (although I don’t like to waste it) but there are occasionally issues with updates and duplications using RSS the way we do. I wonder if JSON will straighten some of that out. Angular also opens up a realm of options as you get closer to writing code rather than relying on plugins. And finally, I want to knit Discourse more tightly to WordPress. That’ll matter because of the strong resistance to “another site?” responses. What can you get out of Discourse via JSON? Short answer- lots of stuff. Much like WordPress you can […]