Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,740
Website GitHub

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. Bleeding-edge code available on GitHub.

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: 10,740
Website GitHub

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. Bleeding-edge code available on GitHub.

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

#31 2011-03-05 15:44:15

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,740
Website GitHub

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.

Txp Builders – finely-crafted code, design and Txp

Offline

#32 2011-03-05 19:51:16

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

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

#33 2011-03-05 21:15:28

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

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

I’m starting to think the way to go might be make all the category pages sections. Although that would mean a lot more pages and code and would be sloppy. But I don’t see any way to maintain the current category page once an individual article is selected.


its a bad hen that wont scratch itself.
photogallery

Offline

#34 2011-03-06 14:49:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,740
Website GitHub

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

kvnmcwebn wrote:

Everything is working fine until you drill down to an individual article in a category page…. I’m starting to think the way to go might be make all the category pages sections.

We’re nowhere near ready to throw the towel in yet!

Thanks for the link to your site. That’s helped a lot. So the issue is that the site ‘forgets’ the category when you drill down. So all we need to do is help it remember. Perhaps on your list page, do something like this:

<txp:if_category>
<h3 class="entry-title"><a href="<txp:permlink />?cat=<txp:category />"><txp:title /></a></h3>
<txp:else />
<h3 class="entry-title"><txp:permlink><txp:title /></txp:permlink></h3>
</txp:if_category>

And then later in the page where you have the smd_prev/smd_next, read that variable in using <txp:adi_gps /> and then use it:

<txp:smd_prev category='<txp:if_variable name="cat"><txp:variable name="cat" /></txp:if_variable>' >
   <txp:smd_link_to_prev urlvars="cat">&laquo; Previous</txp:smd_link_to_prev>
</txp:smd_prev>

Notice I’ve used <txp:smd_link_to_prev> because we want to use the urlvars attribute to preserve the ?cat URL var in the links.

Through judicial use of the datasort atribute as I mentioned above you should be able to limit the navigation to the given category.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#35 2011-03-06 15:11:46

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

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

>>…So the issue is that the site ‘forgets’ the category when you drill down. So all we need to do is help it remember…

:) I like that.

Well I’ve got my homework now. Thanks a mill Steph.


its a bad hen that wont scratch itself.
photogallery

Offline

#36 2011-03-06 15:43:01

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

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

Steph before moving on to step two using <txp:adi_gps /> is this how the individual article category urls should look?:

http://www.graphx.macdesign.eu/signs/signs-example-14?cat=business_signs

thanks


its a bad hen that wont scratch itself.
photogallery

Offline

Board footer

Powered by FluxBB