Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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.
Offline
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. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
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
Re: smd_horizon: What's that coming over the hill...
Hi mr bloke,
I am ordering articles with numeric values entered in a custom_field, where “01” comes before “02”, etc etc
The plugin works great except that the next and previous articles don’t reflect the order specified by custom_field.
Is there a way to make the tag honor my desired article order because using the datasort attribute doesn’t seem to work?
<txp:smd_next datasort="custom_12 asc" category='<txp:category2 />' form="-pag-next" />
<!-- form="-pag-next" -->
<txp:smd_if_end>
<txp:else />
<a href="<txp:link_to_next />" rel="next" class="next">Volgende pen: <txp:custom_field name="Kleur" /></a>
</txp:smd_if_end>
Last edited by Timid&friendly (2010-06-11 07:27:06)
I think, therefore I AM, … … er … I think :-?
Offline
Re: smd_horizon: What's that coming over the hill...
Timid&friendly wrote:
next and previous articles don’t reflect the order specified by custom_field.
No, I never considered that. Stupid really. To test this out, hack the plugin for now. Find line 241ish. You’ll see:
case 'author':
if ($author) {
$orderby[] = 'AuthorID'.$sorder;
}
break;
Add this immediately afterwards:
default:
$orderby[] = $item.$sorder;
pieman
Sorry for not getting back to you at the time but this fix will help you too. If you want to use timesort though you’ll need to edit line 260ish as well. Remove the line with default: on it and paste it below the ‘posted’ case, like this:
case 'posted':
$orderby[] = 'Posted'.$sorder;
break;
default:
$orderby[] = $item.$sorder;
Let me know how y’all get on. If it works and there are no undue side-effects I’ll issue an official version.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_horizon: What's that coming over the hill...
That works fantastically! Thx so very much
I think, therefore I AM, … … er … I think :-?
Offline
Re: smd_horizon: What's that coming over the hill...
Hi Stef – I’m trying to get next/prev links within a category1. I had some pretty weird stuff happening, but borrowing Maniqui’s final code things more or less work:
<txp:chh_if_data>
<txp:category1 title="1" />
<txp:chh_if_data>
<txp:smd_prev category='<txp:category1 />'>
<txp:smd_if_start>
<txp:else />
<a href="<txp:permlink />" class="breadcrumbs">
« <txp:prev_title />
</a>
</txp:smd_if_start>
</txp:smd_prev>
</txp:chh_if_data>
<txp:chh_if_data>
<txp:smd_next category='<txp:category1 />'>
<txp:smd_if_end>
<txp:else />
<a href="<txp:permlink />" class="right breadcrumbs">
<txp:next_title /> »
</a>
</txp:smd_if_end>
</txp:smd_next>
</txp:chh_if_data>
</txp:chh_if_data>
Only, Instead of the order getting sorted by posted it seems to sort it alphabetically by title.
So instead of:
Conway House > Rockwell-Hondorp Residence > Inglese Queen Truss House
I get:
Conway House > Hapgood Residence > Harwood Stone House
Won’t you please help me, Mr. Bloke,
– A shy admirer.
Last edited by JanDW (2010-08-25 16:03:32)
TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX
Offline
Re: smd_horizon: What's that coming over the hill...
JanDW wrote:
Instead of the order getting sorted by
postedit seems to sort it alphabetically by title.
Hmmm, I just tried this and got a bit confused. From my testing I think if you dig a little deeper you may find that it’s actually sorting by category2 (first) and then in the absence of a cat2 will default to posted. This may well be a bug (or at least an “unexpected feature” :-) but I think as soon as you choose ‘category’ as a horizon it takes both categories into account. Since it can’t know which you want to sort by it goes by cat1 first, then cat2. In your case, cat1 is all the same so it sorts by cat2.
I’m not sure how to get round this one. Might be something I can do in the plugin, or some clever soul might be able to find another way to approach it. Gotta run now. Will divert some brain cycles to it myself later if I can.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_horizon: What's that coming over the hill...
Ah yes that would make sense as category2 is virtually identical to the title of each.
I didn’t think of that, so I was baffled that it seemed to sort by title. Thanks for pointing that out.
Well, I just added datasort="category1":
<txp:smd_prev category='<txp:category1 />' datasort="category1">
and to <txp:smd_next> as well and I think it now sorts by posted secondly!
Thanks Stef!
Last edited by JanDW (2010-08-25 19:27:09)
TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX
Offline
#25 2010-12-07 04:49:05
- marshieparshie
- New Member
- Registered: 2010-12-06
- Posts: 3
Re: smd_horizon: What's that coming over the hill...
smd_if_start/end aren’t working for me. the most basic code i tried is:
<txp:smd_if_start type="category2">test</txp:smd_if_start>
this goes at the top of the article. the first article in category2 does not have “test” at the top. no article has it. in debugging i get
[<txp:smd_if_start type="category2">: false]
the article viewed is the first article posted, so it must be the start of category2, yes? there is another bit of code that checks if the article has a “category2” value, and it works fine.
Last edited by marshieparshie (2010-12-07 04:49:59)
Offline
Re: smd_horizon: What's that coming over the hill...
Hi,
I’m trying to get prev and next to work only within a category as well. First the plug in works in 4.03 right? The documentation, if i understand it correctly, says the current category is on by default. But when I use the smd_prev and next tags they pull up articles from all categories in that section.
Is there a way I can get smd prev next to only pull up articles in the current category and if so can i do it without using if category?
JanDW’s post looks interesting but I have multiple categories in each section of this site i’m working on.
Here’s the code im using, current is just a variable for the current category. any advice appreciated. Thanks.
<ul id="previous-next">
<li id="n-previous">
<txp:if_individual_article>
<txp:smd_prev category="CURRENT"><txp:link_to_prev>« Previous</txp:link_to_prev></txp:smd_prev>
<txp:else />
<div class="older"><txp:older>Older Projects »</txp:older></older>
</txp:if_individual_article>
</li>
<li id="n-next">
<txp:if_individual_article>
<txp:smd_next category="current"><txp:link_to_next>Next »</txp:link_to_next></txp:smd_next>
<txp:else />
<div class="newer"><txp:newer>«Newer Projects </txp:newer></div>
</txp:if_individual_article>
</li>
</ul> <!— end previous-next —>
its a bad hen that wont scratch itself.
photogallery
Offline
Re: smd_horizon: What's that coming over the hill...
kvnmcwebn wrote:
First the plug in works in 4.03 right?
4.3.0 yes; 4.0.3 not so sure.
The documentation… says the current category is on by default.
The documentation probably sucks. It’s true that it defaults to the current category but only if you are viewing a category via the URL, e.g. site.com/category/some-cat. In that instance it will only navigate between all the articles with category1 or category2 set to some-cat. If you’re viewing a normal individual article then it’ll only be using the section as a filter and will thus view all articles, exactly like the built-in tags do.
If you want to only navigate through the current category(ies) that belong to the currently viewed article you’ll need to populate the category attribute of smd_next/smd_prev. You’ll probably need to be clever here, but watch out for pitfalls. Here’s an approach that seems on the surface to work, assuming that category1 is always populated and category2 might be populated:
<txp:smd_next
category='<txp:category1 />
<txp:if_article_category number="2">,<txp:category2/></txp:if_article_category>
'>
<txp:link_to_next>Next »</txp:link_to_next>
</txp:smd_next>
And the same for smd_prev of course. That tells it to use the current category1,category2 as filters so you’ll navigate between all articles in the current seciton that have either of the categories in the currently viewed article. Sounds good, right? But there’s a catch.
You probably won’t want to do this in real life because it means your nav gets funky if you move to the next article and it has a different pair of categories from the one that preceded it. It will always share one of them of course. Best way to demonstrate this is by example:
Article 1: cat1 = foo, cat2 = bar
Article 2: cat1 = foo, cat2 = baz
Article 3: cat1 = jim, cat2 = bob
Article 4: cat1 = jim, cat2 = baz
Starting at Article 1 and clicking Next through them, you would then see this sequence:
Article 1: Prev=empty, Next=Article2 (because foo is the same as the current cat1)
Article 2: Prev=Article1, Next=Article 4 (because baz is the same as the current cat2)
Article 4: Prev=Article3 (because jim is the same as the current cat1), Next: empty
So you can see that the next/prev changes depending on the combination of cat1 and cat2, which is pretty weird for your visitors. That’s why the best way to use smd_horizon is to use it when you are viewing a category list via site.com/category/foo, otherwise you should probably pick one category (1 or 2) and force the navigation to use that. If you don’t — and you try to use both categories at once — things get very confusing very quickly!
Hope that helps and hasn’t confused you even further :-)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_horizon: What's that coming over the hill...
thanks. ha ha I am confused further but it’s probably not your fault.
I only want to navigate through one category at a time and the category will be in the url. But there are up to 5 categories per section so if I don’t need to use if_category it will save a lot of code. Maybe all i need is this:
<ul id="previous-next">
<li id="n-previous">
<txp:if_individual_article>
<txp:smd_prev category='<txp:category1 />' ><txp:link_to_prev>« Previous</txp:link_to_prev></txp:smd_prev>
<txp:else />
<div class="older"><txp:older>Older Projects »</txp:older></older>
</txp:if_individual_article>
</li>
<li id="n-next">
<txp:if_individual_article>
<txp:smd_next category='<txp:category1 />'><txp:link_to_next>Next »</txp:link_to_next></txp:smd_next>
<txp:else />
<div class="newer"><txp:newer>«Newer Projects </txp:newer></div>
</txp:if_individual_article>
</li>
But actually i can’t test it because I see what the problem is that was making me wonder if the plug in wasn’t working. I’m feel a bit of an idiot. Actually when I select one of the articles from the http://www.url.eu/section/?c=category
the url changes back to
http://www.url.eu/section/article
hmm. so i’m not even sure how i wold get to the previous and next nav while staying in the current category….
guess i need to think some more, it would be messy to use sections for the categories, really messy so i hope i can come up with something.
its a bad hen that wont scratch itself.
photogallery
Offline
Re: smd_horizon: What's that coming over the hill...
kvnmcwebn wrote:
I only want to navigate through one category at a time and the category will be in the url. But there are up to 5 categories per section so if I don’t need to use if_category it will save a lot of code.
Hmmm, maybe the issue you’re hitting is the sort order (datasort attribute)? It should work as you describe with the code you specified. If you set debug="1" on you might get a clearer picture of what’s happening.
Can I just recap what you’re trying to achieve please? You want someone to see a list of articles in a particular category, vis-a-vis at URL site.com/category/trumpton you’ll get the following article list:
Huw
Pew
Barney McGrew
Cuthbert
Dibble
Grub
Those articles are sorted by Posted DESC and are listed where either cat1 OR cat2 contain ‘trumpton’. Now if you click on one of those, say ‘Cuthbert’, you’ll be transported to site/com/section/Cuthbert and you want smd_horizon to maintain the above order and have next=Barney McGrew, and Prev=Dibble?
In which case you may have to specify datasort="Posted,Category1" for your smd_prev and smd_next tags. By default it sorts by Section, then Category1, then Category2, then Posted date which is not the same as TXP’s built-in sorting. Ideally, for seamless integration, you want the sort orders to match when navigating in this manner.
See how far you get by experimenting with the sort order. I should probably include an example like this in the help because it throws up a few subtleties on the way smd_horizon works. Sorry for the hair-pulling behaviour of the plugin.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: smd_horizon: What's that coming over the hill...
>>Those articles are sorted by Posted DESC and are listed where either cat1 OR cat2 contain ‘trumpton’. Now if you click on one of those, say ‘Cuthbert’, you’ll be transported to site/com/section/Cuthbert and you want smd_horizon to maintain the above order and have next=Barney McGrew, and Prev=Dibble?
nope :)
I’m working on a site that’s basically a portfolio. It has six sections a load of images in each section.
The sections contain categories to further organize the photos. So the section landing displays all the thumbs and each category displays the appropriate portion of them. Everything is working fine until you drill down to an individual article in a category page. Then previous and next navigates to the previous or next article in the Main level section.
So I guess the problem here is I have three levels. Your above example is only dealing with two as far as I can tell.
section: prev next works fine
http://www.graphx.macdesign.eu/signs/
category: prev next works the same as on the above but should be limited to the thumbs in that category page.
http://www.graphx.macdesign.eu/signs/?c=exhibit-signs
Last edited by kvnmcwebn (2011-03-05 21:10:42)
its a bad hen that wont scratch itself.
photogallery
Offline