Help - Search - Members - Calendar
Full Version: Need help with Previous/Next by category...
Movable Type Community Forum > Additional Resources > Tips and Tricks
bebop
I've tracked down the posts telling how to do Pre/Next using the MTSQL plugin. How would one alter the SQL query to make it work according to the posting date? (it's 'entry_created_on' in the database.) I've got a situation where the posting dates are out of sync with the entry_id order so Pre/Next doesn't move through the entries in chronological order.
Thanks for any help. smile.gif
bebop
girlie
What about entry_modified_on?
bebop
What I'm really having trouble with is altering the SQL query so it works with the new field. Be it entry_created_on or entry_modified_on.

I'm building the blog for a friend who does movie reviews, one per week. I'm using individual archives to access past reviews. When I migrated the old reviews from her static site I manually set the entry dates to reflect their original posting dates. As she is also likely to correct references, or make other edits after the post, it seemed like using entry_created_on made the most sense.

Apparently, I don't understand enough about how the query is built to get it to sort by creation date.

bebop
BTW, the site is here.
girlie
What's the query that you're using?
bebop
Well I started with this:

<$MTArchiveTitle$>



»

And I tried to substitute or add in entry_created_on and then sort on same.
bebop
OK, I obviously don't know how to post that code snippet. How should I do that?

bebop
bebop
OK, here's the query:
CODE
<MTSQLEntries query="SELECT entry_id FROM mt_entry, mt_placement, mt_category WHERE entry_id & #60; '& #60;MTEntryID& #62;' AND category_label = '& #60;MTEntryCategory& #62;' AND category_id = placement_category_id AND entry_id = placement_entry_id ORDER BY entry_id DESC LIMIT 1"> <a href="<MTEntryLink>" title="previous">«</a> </MTSQLEntries>

<a href="<$MTBlogURL$>">Main</a>

<MTSQLEntries query="SELECT entry_id FROM mt_entry, mt_placement, mt_category WHERE entry_id > '<MTEntryID>' AND category_label = '& #60;MTEntryCategory>' AND category_id = placement_category_id AND entry_id = placement_entry_id GROUP BY entry_id ASC LIMIT 1"> <a href="<MTEntryLink>" title="next">»</a> </MTSQLEntries>


So how to alter it and use entry_created_on
bebop (who has now done some posting homework)
khalido
Someone had posted earlier about having made a plugin to do this... that would be a lot easier to use than the SQL methods.
girlie
Have you tried ORDER BY entry_created_on?
bebop
Yes, that would be the field I would sort on. The problem is getting the correct result set in the first place. The query as it stands returns a result set based on the assumption that entry_id correlates to posting date.

I'm trying to rewrite the query based on entry_created_on, and I think the key is understanding the format of
CODE
<MTEntryDate>.
Does this return/contain a string that matches the format of the entry_created_on field?

Anyway, maybe I need to look at the php solutions. I like the SQL solution because it appears to offer more control over how I display the pre/next links.

BTW, would someone know how to add the functionality to the existing Pre/Next tags as in:
CODE
<MTEntryPrevious category=" ">, <MTEntryNext category=" ">?


best,
bebop
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.