Textpattern Forum

You are not logged in. Register | Login | Help

#11 2009-11-24 16:34:36

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: smd_horizon: What's that coming over the hill...

Hi Bloke,

thanks for this little gem. I’m trying it for the very firs time, with a combo of MLP and gbp_p_l.
I’m having an issue, I would say “inconsistent behaviour”.

I’m trying to create a prev/next navigation for articles on the same category1 of current article.
So, I’ve set up this:

<txp:article...>
...
 <txp:chh_if_data><txp:smd_prev category='<txp:category1 />'><a href="<txp:smd_link_to_prev />" class="button prev-article"><txp:prev_title /></a></txp:smd_prev></txp:chh_if_data>
<txp:chh_if_data><txp:smd_next category='<txp:category1 />'><a href="<txp:smd_link_to_next />" class="button next-article"><txp:next_title /></a></txp:smd_next></txp:chh_if_data>

The smd_prev… works almost fine: when I’m at the first article permalink, it doesn’t output any link to any other article not belonging to category1… that’s cool… unless I remove the wrapping chh_if_data. In that case, I’ll end up with a link to website root, and the txp:prev_title will render the title of an article belonging to the same section, but not to category1.
Do I explain myself?

The smd_next, when I’m at the last article belonging to category1, doesn’t work. It outputs a wrong link to website root (similar to what I said before), and txp:next_title renders the title of another article that belongs to current section, but not to assigned to category1.

Bloke, I hope you have understand my report, as it’s difficult to me to try to explain this in words :)

Thanks.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#12 2009-11-24 16:43:53

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: smd_horizon: What's that coming over the hill...

Oooook.
Thing got fixed when I changed the above snippet to the following one:

<txp:chh_if_data><txp:smd_prev category='<txp:category1 />'><txp:smd_link_to_prev class="button button-arrow prev-article"><span><txp:prev_title /></span></txp:smd_link_to_prev></txp:smd_prev></txp:chh_if_data>
<txp:chh_if_data><txp:smd_next category='<txp:category1 />'><txp:smd_link_to_next class="button button-arrow next-article"><span><txp:next_title /></span></txp:smd_link_to_next></txp:smd_next></txp:chh_if_data>

The difference is the smd_link_to_prev/next used as a container tag instead of used as a single tag.
Now, when I reach the end of txp:category1, I don’t get any undesired output.
And it even works without the wrapping chh_if_data!

Thanks for this gem, Mr. Bloke.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#13 2009-11-24 16:48:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,870
Website

Re: smd_horizon: What's that coming over the hill...

maniqui

Ummm, I think that’s by design but, ummm, I’m not sure. Glad you got it sorted. Shall we brush this one under the carpet and hope nobody else notices ;-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#14 2009-11-24 20:48:16

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: smd_horizon: What's that coming over the hill...

Thanks for the feedback, Bloke.

I still experimenting with smd_horizon, and I’ve noticed something buggy.
If I use article tags (like txp:title, txp:body, txp:permlink), inside smd_prev/smd_next, when I reach the start/end of a list, those tags are rendered using the value of the current article (usually the first/last article).

Expected behaviour: they should return empty (because there isn’t any next nor prev article).
Buggy behaviour: they return the value for current (first/last) article.

Edit: extra question: Bloke, any idea on how to make the links created by smd_link_to_next/prev to be affected by gbp_p_l rules? Most of my permlinks on a page are affected by gbp_p_l, but not the ones created by smd_horizon.

Last edited by maniqui (2009-11-24 20:50:03)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#15 2009-11-24 22:00:59

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,870
Website

Re: smd_horizon: What's that coming over the hill...

maniqui wrote:

If I use article tags (like txp:title, txp:body, txp:permlink), inside smd_prev/smd_next, when I reach the start/end of a list, those tags are rendered using the value of the current article (usually the first/last article).

Nuts, thanks for the report. I’ll have to try and fix that, but I think it’s a bit tricky :-( You can get round it for now like this:

<txp:smd_next>
   <txp:smd_if_end>
   <txp:else />
      <h3>Coming up next...</h3>
      <txp:title />
   </txp:smd_if_end>
</txp:smd_next>

any idea on how to make the links created by smd_link_to_next/prev to be affected by gbp_p_l rules?

Nope, sorry. I use the core’s permlinkurl_id() function to create the links. I presume by the time smd_horizon has encountered the links, gbp_pl is long gone (it’s loaded early, right?) But having said that, if it correctly intercepts other tags in the page flow, why not mine? Hmmm. Perhaps you could bounce this off Graeme and see if he has any ideas how to get this to play with his plugin. I’ll do whatever it takes… ta!

Last edited by Bloke (2009-11-24 22:01:52)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#16 2009-11-24 22:18:50

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: smd_horizon: What's that coming over the hill...

Hi Bloke, thanks for the tips.

I ended up with this snippet, killing two birds with one shot :)

<txp:chh_if_data>
  <ul class="prev-next-article_nav">
    <txp:chh_if_data><txp:smd_prev category='<txp:category2 />'><txp:smd_if_start><txp:else /><li class="prev-article">Previous article:<br /><a href="<txp:permlink />" class="button button-arrow prev-article"><span><txp:prev_title /></span></a></li></txp:smd_if_start></txp:smd_prev></txp:chh_if_data>
    <txp:chh_if_data><txp:smd_next category='<txp:category2 />'><txp:smd_if_end><txp:else /><li class="next-article">Next article:<br /><a href="<txp:permlink />" class="button button-arrow next-article"><span><txp:next_title /></span></a></txp:smd_if_end></txp:smd_next></txp:chh_if_data>
  </ul>
</txp:chh_if_data>

Applying your last tip (smd_if_start/smd_if_end), allowed me to recreate the prev/next links using txp:permlink (and avoid any extra/undesired output on first/last article).
And txp:permlink is intercepted by gbp_permanent_links, so the output is the expected :)

Anyway, I’ll talk with Graeme about this and will let you know what he says.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#17 2009-11-30 06:12:49

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: smd_horizon: What's that coming over the hill...

Hi Bloke,

I’m using a variation of your plugin help example:

<txp:smd_link_to_next urlvars="countries">
  <txp:title />
</txp:link_to_next>

where my url is http://domain.com/section/title/countries/a-b/. The url outputs the variable like this because of an .htaccess directive I’ve set up, which rewrites this to map: http://domain.com/section/title?countries=a-b.

My problem is that when I use the code above, the link /countries/a-b/ isn’t reproduced.

Is it possible to do this?

Last edited by speeke (2009-11-30 06:15:20)


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#18 2009-11-30 10:48:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 5,870
Website

Re: smd_horizon: What's that coming over the hill...

speeke wrote:

My problem is that when I use the code above, the link /countries/a-b/ isn’t reproduced.

At the moment using urlvars, no it cannot do that. It always outputs messy URLs and can’t read or intepret your permanent link rules unless you do what maniqui did in the post above yours (which is probabyl not applicable here).

Thinking about it, I suppose I could make it more useful by allowing you to specify the format of the desired URL for any parameters. Perhaps I could allow you to specify placeholders where you want your variables to be added, e.g.:

urlformat="/{country_var}/{country_val}"

Without any urlformat it’d default to ?var1=val1&var2=val2...

Not sure if I can pull that off, but if I could it’d be pretty cool. Would that help you out? If so, leave it with me and I’ll see what I can do.

Last edited by Bloke (2009-11-30 10:49:18)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern.

Txp Builders – finely-crafted code, design and Txp

Offline

#19 2009-11-30 21:59:13

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: smd_horizon: What's that coming over the hill...

Bloke wrote:

Not sure if I can pull that off, but if I could it’d be pretty cool.

Not only am I sure you could pull it off, but then not only would the plugin be cool, but so would you – me hoping that this gratuitous praise will be sufficient ;)

Would that help you out? If so, leave it with me and I’ll see what I can do.

Absolutely :-)

Otherwise, I imagine I’ll have to use a menagerie of plugins/php code to try and reproduce this??? Thank you in advance!

EDIT: BTW, would it also be possible to create options for whether rel= and title= are included in the link output? I prefer not to use title in a link, for example, due to accessibility issues. As I understand it, screen readers, used by people with a visual impairment, end up “reading out” the link and the title name, which creates unnecessary “noise”.

Last edited by speeke (2009-11-30 22:58:00)


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#20 2010-02-09 16:03:42

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: smd_horizon: What's that coming over the hill...

Hi Stef

I’m scouting for a prev/next device that will play nicely with stm_article_order

I made a speculative stab at using txp:smd_next with stm_article_order’s sort="position" atrtribute

<txp:smd_next timesort="position" />

I crossed all my fingers and toes, but not surprisingly it didn’t have the desired effect. Do you think it might it be possible?

Offline

Board footer

Powered by FluxBB