Help - Search - Members - Calendar
Full Version: Display latest blog title outside MT?
Movable Type Community Forum > Additional Resources > Tips and Tricks
gwb
I've searched forum high and low for answer to this question. Maybe I missed it.

In very straightforward terms, can someone explain how and if I can do the following:

On our main site page I want to display the latest blog title subject posting. This main page is outside of MT blog. It would serve as a teaser to get readers to go to the blog and the teaser text would be updated with each MT posting - the latest one would be displayed on this main page.

I know it would involve an SSI call on the main page and some kind of MT template. But beyond that, I'm lost. So, how do I extract the latest blog title into a document of some sort, then call that via SSI to the main page?

Thanks in advance
imabug
there are several ways you could do this. setting up a simple PHP snippet to query the MT database for the most recent entry title and printing it out would be pretty trivial to do.

You could also create an index template in MT and have it spit out just the title of the most recent entry to a file. Then use PHP or SSI to include the file into your main site..

you might even think about having MT generate your main site page for you.
gwb
Thanks for the prompt response.

I've never used PHP.

So, as to the other alternative you suggest, what is the exact MT code I would use to "create an index template in MT and have it spit out just the title of the most recent entry to a file?" I do SSIs all the time, so that part I do understand. So if I can just get the latest title over into a document, I'm home free from there.

Thanks in advance.
nammer
In your Templates screen, click on "create a new index template". Name it Latest Entry Title, or something equally profound. Set the output file to "entrytitle.txt" or perhaps even "entrytitle.shtml" (I use PHP, so I'm relying on you to make the right choice here smile.gif ) And try something like
CODE
<$MTEntries lastn="1"$>
<$MTEntryTitle$>
<$/MTEntries$>
or
<$MTEntries lastn="1"$>
<a href="<$MTEntryPermaLink$>><$MTEntryTitle$></a>
<$/MTEntries$>


Save and rebuild, then include the outputted file into your main page.

Does that help?

Donna
gwb
I just tried as you suggested by creating a new template with an output file set to something.txt. I enabled the "rebuild this template automatically." And when I rebuilt, this error was thrown:

CODE
"Parse error in template 'Latest Entry Title': <MTEntries> with no </MTEntries>"


Also, when I disabled the "rebuild this template automatically" it rebuilt fine. But - sorry to seem dense - where does the something.txt file live? How do I call it via the ssi when I haven't a clue where it lives.

I also tried the "link this template to file" option and I uploaded the actual code file to the server. And when I called that file via ssi, all I saw was the raw MT code displayed.

It just doesn't seem to be outputing any text?
LisaJill
Can you paste the entire template of something.txt here, use the code buttons to make sure it shows. The error message is very clear, just have to find out where it is and fix it. =)

Also, when you created the index template "something.txt" you gave it an output file I assume "something.txt". That would rest in the local site path/url that you set up in your weblog config, core screen.

Same place where the MT generated index.html sits. =)
gwb
here's the code that constitutes something.txt template:

CODE
<$MTEntries lastn="1"$>
<$MTEntryTitle$>
<$/MTEntries$>


And, yes, I did think that something.txt might output in same folder as index.htm, archives.html etc. It did not.

Is there additional code that should go in something.txt.

Thanks in advance.
LisaJill
If you get an error, it won't be generated. You have to wait for it to succeed.

One sec I'll test that code on my test page.
LisaJill
I got the same error, but changed the template to fix it, try this:

CODE
<MTEntries lastn="1">
<$MTEntryTitle$>
</MTEntries>


the $ signs are meant to be ok but not working, I never use 'em anyway, so... =)
gwb
You rock! That worked perfectly.

Thanks for all the help today. I feel so much better now. biggrin.gif
LisaJill
M'pleasure. =)
arbtree
I would love to show most recent entries/recently updated for all blogs on my server (similar to the MT home page).

There are several user blogs and I've created a MT blog called index (this was going to be my blogging community homepage) and added code for most recent comments and recent entries etc but realised I have to rebuild it each time to show the latest.

Would love to know if there is a simple bit of code others have used to include either on an html page or on an MT blog page that would automatically update with each new posting. Thanks.
kadyellebee
One way to do this so that no rebuild is required is to pull the data directly out of the database. My Multiple blog Updates List tutorial does that - but you need to be using PHP and the MySQL backend.

Another idea is to set up an index template in each of the blogs and then include those onto your index. Blogstyles' Portal Tutorial has the way I made my portal page.

Hope one of those ideas help,
Kristine
arbtree
Thanks
QUOTE
My Multiple blog Updates List tutorial

did it for me
If I don't want to specify a blog ID (want all blogs latest updates) how should I change the code? Also, is there a way to specify only a certain number of latest entries to show? Many thanks
kadyellebee
Okay, in the first select statement, change it from this:
CODE
SELECT blog_id, blog_site_url, blog_name, blog_description FROM mt_blog WHERE (blog_id = 2) or (blog_id = 3) or (blog_id = 4) or (blog_id = 5) or (blog_id = 8) or (blog_id = 10) or (blog_id = 14)

to this
CODE
SELECT blog_id, blog_site_url, blog_name, blog_description FROM mt_blog


And then to define a certain number of entries, can you clarify what you want to show up? Do you mean how many entries per blog or how many entries total should be in the list? Or maybe I'm missing what you are looking for entirely. wink.gif

Kristine
arbtree
sorry, how many entries total in the list (eg n=20) - right now it seems to show every entry for me (so it's a long list). Is it possible to ask it to show latest 10 entries or latest from past 5 days etc? Thanks.
arbtree
Hi Kristine, any answer to this? Many thanks, Andy smile.gif
imabug
QUOTE (arbtree @ Feb 4 2004, 03:10 AM)
Thanks
QUOTE
My Multiple blog Updates List tutorial

did it for me
If I don't want to specify a blog ID (want all blogs latest updates) how should I change the code? Also, is there a way to specify only a certain number of latest entries to show? Many thanks

for the most recent published entries from all the blogs in the database ordered by date, try this:
CODE
SELECT blog_id, blog_site_url, blog_name, blog_description, entry_id, entry_title, entry_text, author_name
FROM mt_blog, mt_entry, mt_author
WHERE mt_blog.blog_id=mt_entry.entry_blog_id AND mt_entry.entry_author_id=mt_author.author_id AND mt_entry.entry_status=2
ORDER BY entry_created_on DESC
LIMIT n

replacing n with however many entries you want to retrieve
arbtree
Thanks!
If I also wanted to show "List of all Blogs" and "Recent Comments" using the above code, what would I need to change?
arbtree
Thanks!
If I also wanted to show "List of all Blogs" and "Recent Comments" using the above code, what would I need to change?
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.