Sunday, January 17th, 2010 (updated 1 Mar ’10)

Documentation for Nearby Entries v1.1.3

Username

Password

Forgot your password?

Register

Elsewhere...

More and more of OpinionJournal goes behind the paywall. Personally I think it’s the right move, because what’s there to lose? If we won’t pay, the business was over anyway. And my bet is we will.

Macworld Expo 2010 Best of Show.

On chatroulette.com.

Russell Beattie: What we really wanted was a MacPad not an iPad.

Sikuli, ingenious GUI scripting. Definitely going to try it.

This video of a tablet mockup makes me horny at last for a tablet computer. I’m excited for tomorrow’s Apple announcement. Guess I’ll be standing in line to buy one as well.

A Little Less Conversation, says Joel Spolsy.

Fake Steve Jobs pens the most insightful piece I’ve read on Google’s complaints vis-a-vis China.

Hypercritical by John Siracusa, or, The Tao of Editing.

A test of input device speed for a 221-word passage.

With the Nearby Entries plugin, you can display not only one but any number of next and previous entries. You can order next/previous links not only chronologically by entry_date but alphabetically by title or chronologically by edit_date or expiration_date. You can also display custom fields from next/previous entries. And you can filter next/previous entries using standard weblog:entries parameters such as status, category, author and custom fields.

Compatibility

Works with both EE v1 and v2.

Installation

EE v1.x

Place the pi.nearby_entries.php file in the /system/plugins folder.

EE v2.x

Create a folder /nearby_entries within the /third_party folder. Place the pi.nearby_entries.php file in there.

Tags

The plugin has two tags, both used the same way: exp:nearby_entries:next and exp:nearby_entries:prev.

Parameters

Required parameters

this_entryid

This is the entry from which the previous and next entries are determined. Required unless both the this_urltitle and this_weblog parameters are entered instead.

this_urltitle

This is the entry from which the previous and next entries are determined. Requires completing the this_weblog parameter as well.

this_weblog / this_channel

Helps determine the entry from which the previous and next entries are determined. Required if determining the entry using the this_urltitle parameter. Use this_weblog for EE v1, this_channel for EE v2.

site

Required if using the Multiple Site Manager.

Optional parameters

author_id

Works as in the weblog:entries tag.

category

Works as in the weblog:entries tag.

category_group

Works as in the weblog:entries tag.

day

Works as in the weblog:entries tag.

debug

Allowed values are Yes, yes, y or No, no, n. When set, no results are displaye; instead, a series of notes about the deployment of the plugin appear within a div of class “nearby-entries-message”. These notes should help debug usage of the plugin if the results aren’t as expected.

fixed_order

Works as in the weblog:entries tag.

group_id

Works as in the weblog:entries tag.

limit

Works as in the weblog:entries tag.

month

Works as in the weblog:entries tag.

offset

Works as in the weblog:entries tag.

orderby

Works as in the weblog:entries tag, except the only allowed values are all the columns in the exp_weblog_titles table, among them entry_date (default), edit_date, expiration_date, recent_comment_date and title.

parse

Setting parse=“inward” allows another plugin to be placed within External Entries. (This is a universal parameter that works in all plugins.)

search:[field_name]

Works as in the weblog:entries tag.

show_expired

Works as in the weblog:entries tag.

show_future_entries

Works as in the weblog:entries tag.

sort

Works as in the weblog:entries tag.

status

Works as in the weblog:entries tag.

sticky

Works as in the weblog:entries tag.

start_on

Works as in the weblog:entries tag.

stop_before

Works as in the weblog:entries tag.

year

Works as in the weblog:entries tag.

Variables

{nearby:count}

Works as in the weblog:entries tag.

{nearby:total_results}

Works as in the weblog:entries tag.

{nearby:[field_name]}

Text input and text area custom fields can be displayed.

Relationship fields cannot be displayed (though try the Tied Entries plugin for that!).

Date variables cannot be displayed the regular way, ie, {tied:entry_date format=”%D/%M/%Y”}. Instead, use PHP (set the PHP parsing stage to “output”):

<?php echo date("D/F/Y""{tied:entry_date}"); ?> 

Note that PHP’s date format codes are slightly different to EE’s own. They’re posted at PHP’s date function manual page.

Examples

For a site using the blog-standard /year/month/date/url_title format for URLs, for which ExpressionEngine is not designed, the standard next/previous tags simply don’t work. So we need to use the Nearby Entries plugin instead:

<div class="nextprev nextprev-single">
    <
div class="nav-previous">
        <
span class="nextprev-arrow">&lsaquo;</span>
        
{exp:nearby_entries:prev this_urltitle="{segment_4}" this_weblog="blog" debug="n" limit="1"}
        
<a href="{path=/}<?php echo date("Y/m/d", "{nearby:entry_date}"); ?>/{nearby:url_title}">
            <
span class="nextprev-post">Previous Post</span>
            <
span class="nextprev-single-link-title">{nearby:title}</span>
        </
a>
        
{/exp:nearby_entries:prev}
    
</div><!-- /.nav-previous -->
    <
div class="nav-next">
        
{exp:nearby_entries:next this_urltitle="{segment_4}" this_weblog="blog" debug="n" limit="1"}
        
<a href="{path=/}<?php echo date("Y/m/d", "{nearby:entry_date}"); ?>/{nearby:url_title}">
            <
span class="nextprev-post">Next Post</span>
            <
span class="nextprev-single-link-title">{nearby:title}</span>
        </
a>
        
{/exp:nearby_entries:next}
        
<span class="nextprev-arrow">&rsaquo;</span>
    </
div><!-- /.nav-next -->
</
div><!-- /.nextprev --> 

Note that date fields cannot be output in the usual way, but instead need some assistance from PHP (be sure to switch on PHP for the template).

Changelog

v.1.1.3 (2010 Mar 1)

  • fixed bug where variables weren’t resetting for checking version when plugin called more than once on a template

v.1.1.2 (2010 Mar 1)

  • fixed bug where using parameters this_weblog and this_urltitle instead of this_entryid wasn’t working in EEv2.x

v.1.1.1 (2010 Feb 23)

  • fixed bug where using parameters this_weblog and this_urltitle instead of this_entryid wasn’t working in EEv1.x

v.1.1 (2010 Feb 13)

  • now works for both EE v1 and v2

v.1.0.4 (2010 Jan 29)

  • declared the $output variable so that no PHP messages are sent if it never gets defined

v.1.0.3 (2010 Jan 18)

  • added author_id parameter

v.1.0.2 (2010 Jan 17)

  • added offset, group_id, sticky, fixed_order parameters

v.1.0.1 (2010 Jan 17)

  • added category and category_group parameters

Roadmap

  • add multiple weblog support, ie, piping in the this_weblog parameter
  • change this_weblog parameter to this_channel for EE v2

Mon 18 Jan ’10
4:11pm

Terry Evans

This extension loolks really great.

Say I have a weblog and I want to show the next previous entries of only the currently viewed weblog entry’s author.  Is it possible to filter entries by author?

Mon 18 Jan ’10
4:15pm

Adam Khan

Yes, there’s an author_id parameter, documenting it now.

Mon 18 Jan ’10
4:39pm

Terry Evans

Awesome. This solves a major hurdle for me. Sending $$ to you today.

Mon 18 Jan ’10
4:53pm

Adam Khan

Excellent, post here if any problems. Remember the debug=“y” parameter can be helpful if you’re not getting the results you expect.

Mon 18 Jan ’10
5:51pm

Adam Khan

My mistake, the reason the author_id parameter wasn’t documented is because it wasn’t there. Now added in v1.0.3.

Thu 21 Jan ’10
2:53am

Steve Hurst

It figures, I just solved this issue with custom query tags… where were you a month ago? :)

Fri 29 Jan ’10
9:45am

shine

Hi Adam,

Using the above example returns:

Notice: Undefined variable: output in /home/club/public_html/admin/plugins/pi.nearby_entries.php on line 364

Notice: Undefined variable: output in /home/club/public_html/admin/plugins/pi.nearby_entries.php on line 364

I have enabled php for the template. I am basically trying to use the plugin to mimic something textpattern or wordpress does out of the box whereby you can link to next and previous entries in the same weblog.

e.g. http://www.opensourcecms.com/demo/1/85/Textpattern demo showing linking to next and previous at the bottom.

Any help would be great. Cheers!

Shine

Fri 29 Jan ’10
3:01pm

Adam Khan

Shine,

I’ve updated to v1.0.4 so that there won’t be a PHP notice from if the $output variable never gets defined.

A couple of things: are you sure you even need this plugin? If you just need a simple single next and previous from the same weblog, EE’s own built-in next and previous tags should be fine.

If you’re not getting any output at all, try the debug=“yes” parameter and see what it tells you.

Fri 29 Jan ’10
3:40pm

shine

Adam thanks for you quick response and fix.

I have looked at the built-in ee next and previous tags over at http://expressionengine.com/docs/modules/weblog/entry_linking.html

I was unaware I could do what I wanted with the built-in tags because I was not getting any output.

For example I have a weblog called spring collection. I then have for example 10 entries called tops, jeans, shoes etc etc.

I simply want the user to land on the page and view the latest entry and then have a button to have a link to the next and previous entries within the same weblog.

I assumed that your plugin was necessary to get this working.

Just will have to play about with both options to see if I can execute what I want.

Thanks once again.

Shine

Tue 23 Feb ’10
8:01pm

Tyler

I have just set the this_weblog (text) and this_urltitle (segment var) but still get no output. I have set debug to “yes” and I get this

Method: prev

This entry ID:

Prelim query:

Raw results: Array

Fields SQL:

Nearby Entries errors:

If there’s no entry_id there must be both a url_title and a weblog_name.

It looks like its not pulling the url_title / weblog to determine which entry it should be. Please help. Thanks!

Tue 23 Feb ’10
11:33pm

Adam Khan

Tyler, you’re right, it’s a bug introduced with v1.1, making the plugin compatible with both EE v1 and v2. Try the new version, v1.1.1, that should address the problem. (Good to see the debug option in use!)

Tue 23 Feb ’10
11:43pm

Tyler

Now were talking! Does exactly what I want. Brilliant plug-in!

Tue 23 Feb ’10
11:50pm

Adam Khan

Thanks, Tyler, pleased to hear it.

Tue 23 Feb ’10
11:58pm

Tyler

Using it with Low Seg2Cat to completely free up the URL structure in EE.

Wed 24 Feb ’10
9:37am

Adam Khan

> Using it with Low Seg2Cat to completely free up the URL structure in EE.

Crazy sh*t. Would be interesting to see an article on this.

Sun 28 Feb ’10
11:55pm

trif3cta

Fantastic plugin idea, although I’m having the same issue that Tyler was. I’m using 1.1.1.

I’m providing this_urltitle=’{segment_x}’ and this_weblog=‘channel_name’ in debug mode and getting back:

If there’s no entry_id there must be both a url_title and a weblog_name.

Thanks for the help.

@Tyler - pls do share, that sounds wicked.

Mon 1 Mar ’10
9:22am

Adam Khan

trif3cta, are you using Multiple Site Manager?

Mon 1 Mar ’10
3:16pm

trif3cta

Nope. My setup is like so:

/staff/profile/name

Name (segment 3) is what I want to key off, and I have a channel called staff.  So this_urltitle=”{segment_3}” this_weblog=“staff” gives me the error.

The entry ID method returns the right data, however it’s not what I need in this particular case.

Thanks so much for the help.

Mon 1 Mar ’10
5:59pm

Adam Khan

trif3cta, it wasn’t working in EEv2. Try downloading v1.1.2.

Mon 1 Mar ’10
7:59pm

trif3cta

Thanks Adam, that seemed to fix it. 

For some reason I can’t run both functions in the same template, whichever one listed first outputs the results of the query and the other one is blank (or in debug mode, it gives the (If there’s no entry….).

Forgive me if I’m being dense.

Mon 1 Mar ’10
8:58pm

Adam Khan

trif3cta, the density is all mine. Fixed in v1.1.3…

Tue 2 Mar ’10
2:42am

trif3cta

Works like a charm. Gracias.

Post a comment

Name:

Email:

Location:

URL:

Your comment:

Remember my personal information
Notify me of follow-up comments?

Please enter the word you see in the image below: