How to group ModX Revolution GalleryAlbums by year - modx

How is it possible to group albums by year?
For example:
2014
- Album 1
- Album 2
2013
- Album 3
I've recently seen that it is possible to group them in the backend using a subfolder-like approach to sort them - but is it also possible to query albums for a specific folder?
I'm currently using this call in my Gallery overview:
[[!GalleryAlbums? &sort=`year` &albumCoverSort=`random` &rowTpl=`galAlbumRowTpl`
&toPlaceholder=`galleries` &showAll=`1` &parent=`6`
&prominentOnly=`0` &limit=`50`]]
<div class="galleries">[[+galleries]]</div>

Currently the GalleryAlbums Snippet doesn't support sorting by year, even though there's a "year" field for the Album object:
However, there's a couple ways to do this.
1. Write your own Snippet
This would be the most performant option, but instructions for this might be out of scope here, so another option might be:
2. Nested Template Chunks
Organize your albums by nesting them under parent albums named after the year. So you'd have an album called "2014" and under that you'd have child albums you want to display for that year.
Then modify your snippet call to include these properties:
&showAll=`0`
&parent=`0`
According to the Gallery documentation, this is what those properties do:
showAll If 1, will show all albums regardless of their parent.
parent Grab only the albums with a parent album with this ID. Remember to set showAll to 0, otherwise it won't work!
Now modify your rowTpl, so that it's something like this:
<li>[[+name]]
<ul>[[GalleryAlbums? &showAll=`0` &parent=`[[+id]]` ... ]]</ul>
</li>
What this means, is that your "outer" Snippet call gets only "top-level" albums, because you specified that the parent attribute must be "0". Then the tpl for each album calls the Gallery snippet again, with the parent property as the ID of the currently iterated Album, thereby returning a list of child Albums. Note in the above code sample, I've omitted the other important properties like &rowTpl, which you would need to populate.
NOTE: I see you're calling your Snippet with the uncached token !. You might get performance gains by caching it, especially if you use an aggressive caching mechanism like StatCache. Granted the GalleryAlbums getList processor utilizes its own cache handler, but there will likely be performance penalties for using a nested Snippet call like the one I've described here.

Related

How to know if a Google Photos album has changed

I'm using Google Photos API to access albums.
Users can have in an album anything from a single photo to thousands of photos.
Is there a way to get something like an ETag to know if an album has changed since a previous known state?
Currently, the only way I could find is to iterate over all the images, and having to do that in 100 photos each time can take a lot of calls just to find out at the end that nothing has changed.
You want to know whether the album of Google Photos has been changed.
I could understand like above. Unfortunately, in the current stage, there are no metadata like the modified date when the contents in the album were changed. So in my case, I use the following workaround. Please think of this as just one of several workarounds.
Workaround:
If the number of photos in the album is changed, it can be known by the property of mediaItemsCount.
If the cover photo is changed, it can be known by the property of coverPhotoBaseUrl.
If several photos in a album are changed without increasing and decreasing the number of photos, unfortunately, in the current stage, I think that it is required to confirm the creationTime, filename and so on using the method of mediaItems.list.
By confirming from above in order, I can know about the change of the album.
References:
Method: albums.list
Method: albums.get
Method: mediaItems.list

Orchard 1.9.1 Container Layout

I set up the following Content Definition in an Orchard 1.9.1 site:
Manufacturer
- Logo (Media Library Picker Field)
- Container (single supported type - Product)
Product
- Containable
- [Generic Fields]
I added a few sample Product items to the site, and as part of that it had me select the Member Of option, which was a list of Manufacturer items I had already added.
The issue I have is, when I try to build a query to use with a projection widget, I can't seem to find a way to get either a Manufacturer's children, or a Product's parent container since I need to display all content on a single view. There are only going to be ~20 line items here, so performance is a non-issue. If I do multiple queries (one for each type), everything shows up individually but the Shape Tracing tool, when showing me the various Model items on the view, can't seem to show me either of these options.
My end goal is building a custom view to display this information, but I can't figure out how to traverse either up the Product to what its' parent container is, or traverse down from a Manufacturer to the child Product items below it.
How do I build a query that lets me see all of this so I can build a projection widget off of that?
Edit
I played with this some more and came across the ability to take a query and attach a layout to it. That is definitely getting me closer, however the grouping option says No properties are currently available in order to group this view, however I would think being part of a container/containable would define grouping automatically. As it stands, this lets me show everything, but unfortunately the parent/child show, and then the children repeat again, independent of the parent. It's so close, but I can't quite get it right.

Dynamic menu for a List in Orchard

Take the example of an album containing tracks using the List module, per http://weblogs.asp.net/bleroy/many-ways-to-relate-orchard-things-part-3-lists
Is it possible to create a dynamic menu for the list of tracks using the navigation module? I can get it to work by adding the menu part to the track content type, but that creates a lot of steps and maintenance for content creators. The other option is with queries, but that would be too complicated for content creators.
To take it further, the ultimate goal would be to create a dynamic menu for nested lists. An example would be:
Artists: contains Albums
Albums: contained by Artists and contains Tracks
Tracks: contained by Albums
I think I could do this with Taxonomies, but the source content works a lot better with Lists.

Including categories within expression engine

I have created a list view of news articles within Expression Engine. A user can click through on each news article to read the detail. For each entry within the list view I would like to show its associated categories - ie the categories that it has been assigned to.
I am not quite sure how to combine this category information into my channel entries loop.
So within each returned entry in the loop, you want to display the category assignments? If that's the case, just use the categories variable pair within your loop.

Drupal views: limit results shown based on CCK field setting

I have a view that pulls in feed items (from various "Owner feeds" to use the feeds module lingo), then sorts them by date (very important). The owner feed has a CCK field for the type of feed (Twitter, Blog, etc.) and a CCK field theoretically to limit the number of feed items displayed in the view. (The reason for the limit is that Twitter dominates, but we want some blogs, etc., so I don't want to have to show 100 tweets before displaying my first blog.)
I'm guessing some sort of Views hook code is in order, but I'm not sure which one. Perhaps the hook that allows direct modification of the query...
Note that the Owner feed nid is being pulled into the view via a Relationship.
Thanks in advance!
Using the Arguments field in the view, you could first select the node type, then node post date.
In this way you could give priority to the blog type, before sorting by date.
You could also consider building two Views, for instance the top 5 blog items and the top 20 Twitter feeds...

Resources