Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2011-03-06 16:46:41

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

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

kvnmcwebn wrote:

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

That should do the trick, yes. I just chose cat= because we can’t use c= as it’s used internally by TXP. As long as that value is passed forward to each page that originates from a category list you can use that variable for whatever purpose you see fit. Just have to make sure that you aren’t passing any more messy vars about the place or you might end up making ?cat=business_signs?m=2, which ain’t valid.


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

Online

#38 2011-03-06 17:43:32

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

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

Well it’s passing the variable and keeping it for each article in the category but I’m not sure how the adi_gps is supposed to pass the variable to the if variable statement:

From what i read in the adi_gps docs it looks like its all done in the code you posted right:

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

I mean that actually gets the var as well right?


its a bad hen that wont scratch itself.
photogallery

Offline

#39 2011-03-06 17:50:09

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

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

kvnmcwebn wrote:

I’m not sure how the adi_gps is supposed to pass the variable to the if variable statement

Magic :-)

It creates a txp:variable called cat if there’s a ?cat= in the URL. If there isn’t, it’s not created, hence the reason we need to test if it exists using <txp:if_variable>. If you skip the if_variable part and the cat= is omitted a warning shows up on your page.

So, yes, the code I posted gets the value of the variable and plugs it into the smd_next/prev category attribute so it’s passed between pages when you click next/prev. All that remains is to get the right datasort attributes (probably Posted, Category1, Category2?) so it can do your bidding by providing the next/prev links you expect.

Last edited by Bloke (2011-03-06 17:51:19)


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

Online

#40 2011-03-06 17:55:52

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

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

cool thanks, I was wondering why we needed the if_variable
ok going to try the datasort now
fingers crossed


its a bad hen that wont scratch itself.
photogallery

Offline

#41 2011-03-06 18:12:33

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

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

hmm…
any thing wrong with this?

<ul id="previous-next">
<li id="n-previous">
<txp:if_individual_article>
 <txp:smd_prev   category='<txp:if_variable name="cat"><txp:variable name="cat" /></txp:if_variable>' datasort="posted, category1, category2"  >
   <txp:smd_link_to_prev urlvars="cat">&laquo; Previous</txp:smd_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:if_variable name="cat"><txp:variable name="cat"   /></txp:if_variable>' datasort="posted, category1, category2" >
   <txp:smd_link_to_next urlvars="cat">&laquo; Next</txp:smd_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

#42 2011-03-06 19:04:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

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

kvnmcwebn wrote:

any thing wrong with this?

Not as far as I can see. Is it live now? ‘Cos if it is then the component that’s missing (assuming adi_gps is in your page template somewhere) is the ?cat= in your URL. Without that bit the if_variable won’t fire and you’ll be back to navigating a regular section list.


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

Online

#43 2011-03-06 19:45:37

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

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

holy mary mother of god it works. you are the man. I learned a lot from this. THANK YOU.


its a bad hen that wont scratch itself.
photogallery

Offline

#44 2011-03-06 19:48:34

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

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

I think when I get this cleaned up I might put an article in txp tips about it. what do you think. Im mean giving all the credit to where it’s due(not me). Because i think that this could help other users.


its a bad hen that wont scratch itself.
photogallery

Offline

#45 2011-03-06 19:57:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

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

kvnmcwebn wrote:

holy mary mother of god it works. you are the man. I learned a lot from this. THANK YOU.

Excellent. You are most welcome. I learned a lot too.

I’d also forgotten how cumbersome the plugin is when it comes to this level of navigation so it’d be nice to retool it a bit in future to make it easier to accomplish this kind of thing. But keeping a bit of history on where an article came from (section list or cat list) is a little outside TXP’s regular scope so perhaps this level of hoop jumping is justified in this case. If anything strikes me I may take the opportunity to do something about it in future versions.

I think when I get this cleaned up I might put an article in txp tips about it.

Great! No worries about heaping credit on me. The important thing is documenting it so others can get to the end result quicker than it’s taken my foggy brain and slightly awkward plugin to catch up with your, very reasonable, site layout logic :-)


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

Online

#46 2011-03-06 20:00:39

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

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

ha ha. it’s me who is the foggy brained designer!


its a bad hen that wont scratch itself.
photogallery

Offline

#47 2011-05-23 14:34:30

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

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

Thank you for writing this plugin at first :)

Using

<txp:smd_prev category="category1"><txp:link_to_prev><div id="back">&nbsp;</div></txp:link_to_prev></txp:smd_prev><txp:smd_next category="category1"><txp:link_to_next><div id="next">&nbsp;</div></txp:link_to_next></txp:smd_next>

on txp 4.4.0 in an article form produces links still pointing to ALL articles of the current section, independent from a particular category setting.
This also happens, when i use a particular category name instead of “category1” .
Anything i am obviously doing wrong?
Thanx a bunch in advance!

Last edited by jayrope (2011-05-23 14:39:05)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#48 2011-05-23 14:48:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

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

jayrope wrote:

Thank you for writing this plugin at first :)

You’re welcome. Let’s hope it works for you.

… links still pointing to ALL articles of the current section, independent from a particular category setting.

Unless you have a category called “category1” you might fare a little better with the following syntax:

<txp:smd_prev category='<txp:category1 />'> ...

That will populate smd_prev’s category attribute with the actualy category name of the current article. Wrap in a suitable <txp:if_individual_article> construct and that should get you moving.


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

Online

Board footer

Powered by FluxBB