Help - Search - Members - Calendar
Full Version: Sorting Multiple Blogs
Movable Type Community Forum > Additional Resources > Tips and Tricks
bunkalicious
Alright I used Scriptygoddess.com's MT hacks: Multiple blog Updates List to sort 12 of my blogs (works great linkage)

But I want it to display a snipplet of the most recent entry (about 150 characters )and when I added

CODE
SELECT entry_text FROM mt_entry
to the $blogarray; it displays every blog with every post they have ever done and I just want it to display the last entry..

Anyone have any ideas?
kadyellebee
It sounds like you may have added this extra SELECT section onto the first query. That's the one that determines how many blogs there are with their titles and so on.

You'll probably have better luck if you integrate that code into the $maxarray instead of $blogarray - that's what controls the output of the latest entry from each blog.

See the 2nd comment on the SG post for specifics. smile.gif

Kristine
bunkalicious
QUOTE (kadyellebee @ Feb 20 2004, 08:14 AM)
It sounds like you may have added this extra SELECT section onto the first query.  That's the one that determines how many blogs there are with their titles and so on.

You'll probably have better luck if you integrate that code into the $maxarray instead of $blogarray - that's what controls the output of the latest entry from each blog. 

See the 2nd comment on the SG post for specifics. smile.gif

Kristine

thanks but I can;t get it to post right.... php no0b


CODE
<?

//connection info
include ("/home/bloglici/public_html/connect.php");

//for each of the selected blogs (2, 3, 4, 5, 8, 10, and 14) in mt_blog, find and display in descending order the most recent post in mt_entry.

$alldata = array();
$alldates = array();

$blogcount=12; // keep track of number of blogs
$aspace=" "; // define single word space

$blogarray = "SELECT blog_id, blog_site_url, blog_name, blog_description FROM mt_blog WHERE (blog_id = 1) or (blog_id = 12) or (blog_id = 11) or (blog_id = 8) or (blog_id = 23) or (blog_id = 10) or (blog_id = 15) or (blog_id = 18) or (blog_id = 19) or (blog_id = 20) or (blog_id = 21) or (blog_id = 22)";
$resultblog = mysql_query($blogarray) or die (mysql_error());
while ($rowblog = mysql_fetch_array($resultblog)) {

$burl = ($rowblog['blog_site_url']);
$bname = ($rowblog['blog_name']);
$bdesc = ($rowblog['blog_description']);

$rowarray = "SELECT entry_created_on, entry_id, entry_blog_id FROM mt_entry WHERE (entry_blog_id = (".$rowblog['blog_id'].")) ORDER BY entry_created_on DESC";
$resultid = mysql_query($rowarray) or die (mysql_error());

$count=0;
while ($rowid = mysql_fetch_array($resultid)) {
if ($count>0) { break; } //to ensure that if there are less than 1 posts the blog will not break the query

$maxarray = "SELECT entry_text, entry_title, entry_id, entry_created_on FROM mt_entry WHERE entry_created_on = '".$rowid['entry_created_on']."' and entry_id = ".$rowid['entry_id']; $resultmax = mysql_query($maxarray) or die (mysql_error());

$text = substr(strip_tags($rowmax['entry_text']), 0, 125);
$text = substr($text,0,strlen($text)-strpos(strrev($text),$aspace));

while ($rowmax = mysql_fetch_array($resultmax)) {

$ids = array($rowmax['entry_id']);
$date = ($rowmax['entry_created_on']);
$title = ($rowmax['entry_title']);

//saves the data int alldata array for use outside of the while loop
$alldates[$blogcount++] = $date;
$alldata[$blogcount++] = array('bname'=>$bname, 'burl'=>$burl, 'bdesc'=>$bdesc, 'ids'=>$ids, 'title'=>$title, 'text'=>$text);
}

$count++;
}
}
array_multisort($alldates, SORT_DESC, $alldata);

for ($i=0; $i<sizeof($alldates); $i++) {

//separate date created on up between year, month, and date
$year[$i] = substr($alldates[$i], 2, 2);
$month[$i] = substr($alldates[$i], 5, 2);
$day[$i] = substr($alldates[$i], 8, 2);

//echo date, linked blogtitle and latest entry title

echo '<a href="', $alldata[$i]['burl'], '" target="_blank" title="', $alldata[$i]['bdesc'], '">', $alldata[$i]['bname'], '</a></div>';
echo '<div class="update">', $month[$i], '/', $day[$i], '/', $year[$i], ': ', '<br>';
echo '<div class="uptitle">', $alldata[$i]['title'], '</div>', '<br>';
echo '<div class="text">', $alldata[$i]['entry_text'];
}
?>
kadyellebee
I didn't test this out, but I believe that the last line of the code where you are trying to echo the text, it should be referred to as 'text' rather than entry_text.

CODE
echo '<div class="text">', $alldata[$i]['text'];

You probably also want a closing div in that section smile.gif

If that doesn't help, I'll test a bit here. smile.gif

Kristine
bunkalicious
QUOTE (kadyellebee @ Feb 21 2004, 03:02 AM)
I didn't test this out, but I believe that the last line of the code where you are trying to echo the text, it should be referred to as 'text' rather than entry_text.

CODE
echo '<div class="text">', $alldata[$i]['text'];

You probably also want a closing div in that section smile.gif

If that doesn't help, I'll test a bit here. smile.gif

Kristine

thanks but it doesn;t seem to be working for me
kadyellebee
Okay, I looked a bit closer. In addition to the change I made above, your $text variables need to be inside of the while loop instead of before them.

so like this:
CODE
while ($rowmax = mysql_fetch_array($resultmax)) {

$text = substr(strip_tags($rowmax['entry_text']), 0, 125);
$text = substr($text,0,strlen($text)-strpos(strrev($text),$aspace));


Hope that helps,
Kristine
bunkalicious
that cleared it all up; thanks
bunkalicious
would it be possible to add avatars to mysql so when I have everything pulled up it will post the authors picture with it?

http://www.bloglicious.com/index-sort.php
bunkalicious
QUOTE (bunkalicious @ Feb 25 2004, 08:58 AM)
would it be possible to add avatars to mysql so when I have everything pulled up it will post the authors picture with it?

http://www.bloglicious.com/index-sort.php

i figured it out if anyone wants to use this
its nothing too hard

CODE
//avatar try me
echo '<div class="avatar"><img src="', $alldata[$i]['burl'], 'avatar.png', '">', '</div>' ;
bunkalicious
is there a way to add mt_comment from mysql to the sorting script?

I'm using the code from the "code from the multiple blog update list tutorial" and I want it to include the comments for the most recent entry

I want the echo to look like this

Comments (totalnumber)

any ideas?
kadyellebee
Please don't post your question in multiple threads, it makes my head spin in confuse-ment thinking that the same question was asked by different people!!!

see this thread
ikonos
Great stuff what you are doing here!
Thank you bunkalicious and kadyellebee for sharing this.

While this script works like a charm, the only one addition I would need is to link the Entry Title to the Permalink of that entry. Let me tell you that my PERMALINK Archiving algorithm on all my blogs is:

CODE
<MTArchiveDate format="%Y/%m/%d/"><MTFirstNWords n="5" dirify="1"><MTEntryTitle></MTFirstNWords>.htm



In other words I would need to add to this script something like:

CODE
- http://www.domain.com/
+ post date (example: 2004/04/14/)
+ first five words of the title (example: these_are_the_first_five)
+ .htm



I look forward to any suggestion.


With my Best Regards,
Mihai Alexandru Bocsaru
shelley
If your entries are Trackback-enabled, you can grab the URL that way (i.e., SELECT trackback_url FROM mt_trackback WHERE trackback_entry_id=entry_id - would need to merge that with existing code).

Otherwise, there are some tips in this topic on constructing permalinks piece by piece.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.