Textpattern Forum

You are not logged in. Register | Login | Help

#21 2010-06-11 07:21:58

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

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

#22 2010-06-11 09:00:26

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

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.

Txp Builders – finely-crafted code, design and Txp

Offline

#23 2010-06-11 09:17:03

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

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

#24 2010-08-25 16:01:12

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

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">
                    	&laquo; <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 /> &raquo; 
                  </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

#25 2010-08-25 16:35:52

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

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

JanDW wrote:

Instead of the order getting sorted by posted it 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.

Txp Builders – finely-crafted code, design and Txp

Offline

#26 2010-08-25 17:13:15

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

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

#27 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

#28 2011-03-03 15:55:28

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

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>&laquo; Previous</txp:link_to_prev></txp:smd_prev>
<txp:else />
<div class="older"><txp:older>Older Projects &raquo;</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 &raquo;</txp:link_to_next></txp:smd_next>
<txp:else />
<div class="newer"><txp:newer>&laquo;Newer Projects </txp:newer></div>
</txp:if_individual_article>
</li>

</ul> <!— end previous-next —>


its a bad hen that wont scratch itself.
photogallery

Offline

#29 2011-03-05 14:27:50

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

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 &raquo;</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.

Txp Builders – finely-crafted code, design and Txp

Offline

#30 2011-03-05 14:42:33

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

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>&laquo; Previous</txp:link_to_prev></txp:smd_prev>
<txp:else />
<div class="older"><txp:older>Older Projects &raquo;</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 &raquo;</txp:link_to_next></txp:smd_next>
<txp:else />
<div class="newer"><txp:newer>&laquo;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

Board footer

Powered by FluxBB