With the example above, you could theoretically end up with ten entries from the same blog (if it has a much higher posting volume than the other blogs on your installation). You could try this instead, perhaps:
<mt:multiblog include_blogs="all">
<mt:entries lastn="1">...</mt:entries>
</mt:multiblog>
This will get you the most recent entry from each blog on your installation. But this might still not be what you really need. What if you have dozens or hundreds of blogs? You would get a huge list of entries. And they would not be sorted in any meaningful order at all. What if you just wanted the latest entry of each of the ten blogs that most recently published something? Impossible? Not at all:
<mt:multiblog include_blogs="all">
<mt:entries lastn="1">
<mt:entrydate format="%Y%m%d%H%M%S" var="thedate">
<mt:setvarblock name="theentry{$thedate}">...</mt:setvarblock>
</mt:entries>
</mt:multiblog>
<mt:loop name="theentry" sort_by="key numeric reverse">
<mt:unless name="__counter__" gt="10"><mt:var name="__value__"></mt:unless>
</mt:loop>
<mt:multiblog include_blogs="all">
<mt:entries lastn="1">...</mt:entries>
</mt:multiblog>
This will get you the most recent entry from each blog on your installation. But this might still not be what you really need. What if you have dozens or hundreds of blogs? You would get a huge list of entries. And they would not be sorted in any meaningful order at all. What if you just wanted the latest entry of each of the ten blogs that most recently published something? Impossible? Not at all:
<mt:multiblog include_blogs="all">
<mt:entries lastn="1">
<mt:entrydate format="%Y%m%d%H%M%S" var="thedate">
<mt:setvarblock name="theentry{$thedate}">...</mt:setvarblock>
</mt:entries>
</mt:multiblog>
<mt:loop name="theentry" sort_by="key numeric reverse">
<mt:unless name="__counter__" gt="10"><mt:var name="__value__"></mt:unless>
</mt:loop>
This section will take the most recent entry of every blog and put it in a hash, with the entry publication date/time in a numeric format as the key. Finally, the hash is sorted in reverse by key and the first ten items are displayed. Voila, the latest entry from each of the ten blogs that most recently published something...
Tweet
Leave a comment