Mailing List Archive

next prev blog link help
Hi all

I think I figured this nav puzzle out on a project many years ago but can't find my old code.

I want to make next and prev nav links in a blog story that would link to the previous story in the same category - ordered by cover date. There's not a way to use story->list() and Offset => -1 is there? If so it doesn't seem to be working for me.

here's what I have in the Blog story:


my ($next) = $story->list({
element_key_name => 'article',
category_id => $story->get_primary_category->get_id,
unexpired => 1,
publish_status => 1,
limit => 1,
exclude_id => $story->get_id,
cover_date_start => $story->get_cover_date,
Order => 'cover_date',
OrderDirection => 'DESC',
});



my ($prev) = $story->list({
element_key_name => 'article',
category_id => $story->get_primary_category->get_id,
unexpired => 1,
publish_status => 1,
limit => 1,
offset => -1,
exclude_id => $story->get_id,
cover_date_start => $story->get_cover_date,
Order => 'cover_date',
OrderDirection => 'ASC',
});

thanks
Dawn
Re: next prev blog link help [ In reply to ]
On 2011-06-22, at 11:47 AM, Dawn Buie wrote:

> I want to make next and prev nav links in a blog story that would link to the previous story in the same category - ordered by cover date. There's not a way to use story->list() and Offset => -1 is there? If so it doesn't seem to be working for me.

You could get the next story with:
(...other search parameters...
cover_date_start => $story->get_cover_date,
Order => 'cover_date',
Limit => 1,
OrderDirection => 'ASC' )

And the previous story with:
(...other search parameters...
cover_date_end => $story->get_cover_date,
Order => 'cover_date',
Limit => 1,
OrderDirection => 'DESC' )


===
Greg Heo
416.826.7630
http://node79.com
Re: next prev blog link help [ In reply to ]
Hi Dawn,

How about this?


my ($next) = $story->list({
element_key_name => 'article',
category_id => $story->get_primary_category->get_id,
unexpired => 1,
publish_status => 1,
limit => 1,
exclude_id => $story->get_id,
cover_date_start => $story->get_cover_date,
Order => 'cover_date',
OrderDirection => 'ASC',
});



my ($prev) = $story->list({
element_key_name => 'article',
category_id => $story->get_primary_category->get_id,
unexpired => 1,
publish_status => 1,
limit => 1,
exclude_id => $story->get_id,
cover_date_end => $story->get_cover_date,
Order => 'cover_date',
OrderDirection => 'DESC',
});



On Wed, 2011-06-22 at 11:47 -0400, Dawn Buie wrote:
> Hi all
>
> I think I figured this nav puzzle out on a project many years ago but can't find my old code.
>
> I want to make next and prev nav links in a blog story that would link to the previous story in the same category - ordered by cover date. There's not a way to use story->list() and Offset => -1 is there? If so it doesn't seem to be working for me.
>
> here's what I have in the Blog story:
>
>
> my ($next) = $story->list({
> element_key_name => 'article',
> category_id => $story->get_primary_category->get_id,
> unexpired => 1,
> publish_status => 1,
> limit => 1,
> exclude_id => $story->get_id,
> cover_date_start => $story->get_cover_date,
> Order => 'cover_date',
> OrderDirection => 'DESC',
> });
>
>
>
> my ($prev) = $story->list({
> element_key_name => 'article',
> category_id => $story->get_primary_category->get_id,
> unexpired => 1,
> publish_status => 1,
> limit => 1,
> offset => -1,
> exclude_id => $story->get_id,
> cover_date_start => $story->get_cover_date,
> Order => 'cover_date',
> OrderDirection => 'ASC',
> });
>
> thanks
> Dawn
>
>
>

--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret@pectopah.com
www.pectopah.com
Re: next prev blog link help [ In reply to ]
thanks you guys.. I actually DID try that first but it didn't seem to be working.. so I thought me code was flawed.

But it was late.. and now I will try it again in the clear light of day.

Dawn

On 2011-06-22, at 11:56 AM, Bret Dawson wrote:

> Hi Dawn,
>
> How about this?
>
>
> my ($next) = $story->list({
> element_key_name => 'article',
> category_id => $story->get_primary_category->get_id,
> unexpired => 1,
> publish_status => 1,
> limit => 1,
> exclude_id => $story->get_id,
> cover_date_start => $story->get_cover_date,
> Order => 'cover_date',
> OrderDirection => 'ASC',
> });
>
>
>
> my ($prev) = $story->list({
> element_key_name => 'article',
> category_id => $story->get_primary_category->get_id,
> unexpired => 1,
> publish_status => 1,
> limit => 1,
> exclude_id => $story->get_id,
> cover_date_end => $story->get_cover_date,
> Order => 'cover_date',
> OrderDirection => 'DESC',
> });
>
>
>
> On Wed, 2011-06-22 at 11:47 -0400, Dawn Buie wrote:
>> Hi all
>>
>> I think I figured this nav puzzle out on a project many years ago but can't find my old code.
>>
>> I want to make next and prev nav links in a blog story that would link to the previous story in the same category - ordered by cover date. There's not a way to use story->list() and Offset => -1 is there? If so it doesn't seem to be working for me.
>>
>> here's what I have in the Blog story:
>>
>>
>> my ($next) = $story->list({
>> element_key_name => 'article',
>> category_id => $story->get_primary_category->get_id,
>> unexpired => 1,
>> publish_status => 1,
>> limit => 1,
>> exclude_id => $story->get_id,
>> cover_date_start => $story->get_cover_date,
>> Order => 'cover_date',
>> OrderDirection => 'DESC',
>> });
>>
>>
>>
>> my ($prev) = $story->list({
>> element_key_name => 'article',
>> category_id => $story->get_primary_category->get_id,
>> unexpired => 1,
>> publish_status => 1,
>> limit => 1,
>> offset => -1,
>> exclude_id => $story->get_id,
>> cover_date_start => $story->get_cover_date,
>> Order => 'cover_date',
>> OrderDirection => 'ASC',
>> });
>>
>> thanks
>> Dawn
>>
>>
>>
>
> --
> Bret Dawson
> Producer
> Pectopah Productions Inc.
> (416) 895-7635
> bret@pectopah.com
> www.pectopah.com
>
Re: next prev blog link help [ In reply to ]
oh so the trick is use cover_date_end ? I was mixing that up with expire_date.

from the docs Bric::Biz::Asset::Business::Story

cover_date_end
Returns a list of stories with a cover date on or before a given date/time.



thank you
Dawn

> cover_date_end => $story->get_cover_date,


On 2011-06-22, at 11:55 AM, Greg Heo wrote:

> On 2011-06-22, at 11:47 AM, Dawn Buie wrote:
>
>> I want to make next and prev nav links in a blog story that would link to the previous story in the same category - ordered by cover date. There's not a way to use story->list() and Offset => -1 is there? If so it doesn't seem to be working for me.
>
> You could get the next story with:
> (...other search parameters...
> cover_date_start => $story->get_cover_date,
> Order => 'cover_date',
> Limit => 1,
> OrderDirection => 'ASC' )
>
> And the previous story with:
> (...other search parameters...
> cover_date_end => $story->get_cover_date,
> Order => 'cover_date',
> Limit => 1,
> OrderDirection => 'DESC' )
>
>
> ===
> Greg Heo
> 416.826.7630
> http://node79.com
>