ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Query Module Help

December 07, 2007 6:40pm

Subscribe [1]
  • #1 / Dec 07, 2007 6:40pm

    seth.aldridge

    68 posts

    Hi,

    I’ve been working on a solutions for a few days now and I know what I want, but I can’t figure out how to get it.

    I am trying to write a query that will grab the previous post entry_date and url_title_path or similar link to next/previous entry.  However, when I try to write my query I get an error.

    Here is the code I’m using:

    {exp:query sql="SELECT entry_date, url_title_path FROM exp_weblog_titles ORDER BY entry_date ASC LIMIT 2"}
    <a href="http://{url_title_path}">{entry_date format="%Y %m %d"}</a>
    {/exp:query}

    What I’m trying to do is pull the last post and display the date of that post, then I’ll need to be able to use that code again but in reverse in case there in a “Next” post so reversing the ASC order should make it work.

    How would I get the second count rather than the first, going both ways, and what do I need to use to get the {url_title_path} for that post?

  • #2 / Dec 07, 2007 6:43pm

    Lisa Wess

    20502 posts

    For previous, you could just do:

    {exp:weblog:entries weblog="default_site" limit="1" offset="1" disable="categories|custom_fields|trackbacks|member_data"}
    <a href="http://{comment_url_title_auto_path}">Previous</a>
    {/exp:weblog:entries}

    For the next entry, well.. I would still strongly encourage you to actually be using single entry pages.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases