Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2011-09-02 14:02:55
- pafruu
- Member
- From: New Brunswick, Canada
- Registered: 2010-01-14
- Posts: 65
Creating a return to top links after a series of articles
Hello, I’ve been wondering how I could go about doing this.
Here is the situation, I have a couple of articles that are listed in a list and they are separated by category2 in alphabetical order.
here is the code that I have
<txp:if_different><h2 style="padding-top:5px;"><a name="<txp:category2 />" style="Text-decoration:none;"><txp:category2 /></a></h2></txp:if_different><div style="padding-bottom:15px"><h3><txp:title /></h3><txp:if_custom_field name="telephone">Téléphone: 506-<txp:custom_field name="telephone" /><br></txp:if_custom_field><txp:if_custom_field name="cellulaire">Cellulaire: 506-<txp:custom_field name="cellulaire" /><br></txp:if_custom_field><txp:if_custom_field name="fax">Fax: 506-<txp:custom_field name="fax" /><br></txp:if_custom_field><txp:if_custom_field name="email">Courriel: <a href="mailto:<txp:custom_field name="email" />"><txp:custom_field name="email" /></a><br></txp:if_custom_field><txp:if_custom_field name="web">Web: <a href="http://<txp:custom_field name="web" />" target="_blank"><txp:custom_field name="web" /></a></txp:if_custom_field></div>
What I want to do now is add that return to top link which will bring my user to a alphabetical nav.
I tried <txp:if_article_category> and <txp:if_article_list> but I got nothing (or maybe its just me who doesnt understand the lingo) (My bet is on the second option)
How do I go about doing this? Any ideas / suggestions?
Thanks
Patrick
Last edited by pafruu (2011-09-02 14:03:25)
I try, and I try, and I try…. and sometimes I achieve
Offline
Re: Creating a return to top links after a series of articles
Not sure if if_last_article can help.
(Workaround) I am using the plug-in rss_suparchive (orphaned) for my archive page which offers some convenient attributes:
<txp:rss_suparchive_bycat ... showmenu="1" showjump="1" jumplabel="…^…" />
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
#3 2011-09-02 19:31:18
- pafruu
- Member
- From: New Brunswick, Canada
- Registered: 2010-01-14
- Posts: 65
Re: Creating a return to top links after a series of articles
merz1 wrote:
Not sure if if_last_article can help.
Thank you for your quick reply merz1,
I tried it and it went all the way down the list, resulting just one “return to top”. I wonder, is there a way to utilise <txp:if_last_article> per categories in an article list?
I try, and I try, and I try…. and sometimes I achieve
Offline
Re: Creating a return to top links after a series of articles
How about sticking it in your if_different
section that shows between each category. To stop it showing at the top of the list you can use if_first_article
’s else case and to add the missing one at the end of the entire list, you can use if_last_article
:
<txp:if_different>
<txp:if_first_article><txp:else />
<a class="up-link" href="#top">to top</a>
</txp:if_first_article>
<h2>
<a name="<txp:category2 />"><txp:category2 /></a>
</h2>
</txp:if_different>
<!-- rest of your code -->
<txp:if_last_article>
<a class="up-link" href="#top">to top</a>
</txp:if_last_article>
Is that what you are looking for?
Last edited by jakob (2011-09-03 07:37:37)
TXP Builders – finely-crafted code, design and txp
Offline
#5 2011-09-02 21:45:00
- pafruu
- Member
- From: New Brunswick, Canada
- Registered: 2010-01-14
- Posts: 65
Re: Creating a return to top links after a series of articles
jakob wrote:
How about sticking it in your
if_different
section that shows between each category. To stop it showing at the top of the list you can useif_first_article
’s else case and to add the missing one at the end of the entire list, you can useif_last_article
:
<txp:if_different>
<txp:if_first_article><txp:else />
<a class="up-link" href="#top">to top</a>
</txp:if_first_article>
<h2>
<a name="<txp:category2 />"><txp:category2 /></a>
</h2>
</txp:if_different>
<!-- rest of your code -->
<txp:if_last_article><txp:else />
<a class="up-link" href="#top">to top</a>
</txp:if_last_article>
Is that what you are looking for?
Thanks for your reply jakob.
It<s almost the result i<m looking for, however, I get a “to top” link under each article now and the very first category as the title repeated twice.
I tried switching the code around a bit by doing this
<txp:if_different>
<txp:if_first_article><txp:else />
<txp:if_last_article>
<a class="up-link" href="#top">to top</a><txp:else />
</txp:if_last_article>
</txp:if_first_article>
<h2>
<a name=”<txp:category2 />”><txp:category2 /></a>
</h2>
</txp:if_different>
that did not work either, as a matter of fact the whole list disappeared
I try, and I try, and I try…. and sometimes I achieve
Offline
#6 2011-09-02 23:55:45
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Creating a return to top links after a series of articles
if_first/last_article doesn’t work well together with if_different. Have a look at this post for a solution.
Last edited by els (2011-09-02 23:57:09)
Offline
Re: Creating a return to top links after a series of articles
Good catch, Els. My apologies pafruu!
So this should work (and not require a stray comment in the code):
<txp:variable name="article_archive_different" value="" />
<txp:if_different>
<txp:variable name="article_archive_different"><txp:category2 /></txp:variable>
</txp:if_different>
<txp:if_variable name="article_archive_different" value=""><txp:else />
<txp:if_first_article><txp:else />
<a class="up-link" href="#top">to top</a>
</txp:if_first_article>
<h2>
<a name="<txp:category2 />"><txp:category2 /></a>
</h2>
</txp:if_variable>
<!-- rest of your code -->
<txp:if_last_article>
<a class="up-link" href="#top">to top</a>
</txp:if_last_article>
TXP Builders – finely-crafted code, design and txp
Offline
#8 2011-09-03 12:30:40
- pafruu
- Member
- From: New Brunswick, Canada
- Registered: 2010-01-14
- Posts: 65
Re: Creating a return to top links after a series of articles
Thanks for your reply Els.
I looked at the link you posted and tried to adapt it to my needs.
Here is what i got:
<txp:if_different><h2 style="padding-top:5px;"><a name="<txp:category2 />" style="Text-decoration:none;"><txp:category2 /></a></h2><txp:variable name="article_archive_different" value="yes" />
<txp:else />
<txp:variable name="article_archive_different" value="no" /></txp:if_different><div style="padding-bottom:15px"><h3><txp:title /></h3><txp:if_custom_field name="telephone">Téléphone: 506-<txp:custom_field name="telephone" /><br></txp:if_custom_field><txp:if_custom_field name="cellulaire">Cellulaire: 506-<txp:custom_field name="cellulaire" /><br></txp:if_custom_field><txp:if_custom_field name="fax">Fax: 506-<txp:custom_field name="fax" /><br></txp:if_custom_field><txp:if_custom_field name="email">Courriel: <a href="mailto:<txp:custom_field name="email" />"><txp:custom_field name="email" /></a><br></txp:if_custom_field><txp:if_custom_field name="web">Web: <a href="http://<txp:custom_field name="web" />" target="_blank"><txp:custom_field name="web" /></a></txp:if_custom_field></div><txp:if_variable name="article_archive_different" value="yes"><txp:if_last_article><div style="float:right">test 2</div></txp:if_last_article><txp:else /></txp:if_variable>
Unfortunately, I know i did it worng, the test 2 value shows at the very last article of the whole list. I’m missing something..
I try, and I try, and I try…. and sometimes I achieve
Offline
#9 2011-09-03 12:42:20
- pafruu
- Member
- From: New Brunswick, Canada
- Registered: 2010-01-14
- Posts: 65
Re: Creating a return to top links after a series of articles
Thanks for all the help guys it is really appreciated
Jakob thanks for your reply,
I tried your code and what I got is an h2 for all articles and a return to top on all articles.What I am trying to do is summerized like this:
Category2 value=“1”
article1
article2
article3
return to top
Category2 value=“2”
article1
article2
article3
article4
return to top
Category2 value=“3”
article1
return to top
what was rendered with your suggestion was as follows:
Category2 value=“1”
article1
return to top
Category2 value=“1”
article2
return to top
Category2 value=“1”
article3
return to top
Category2 value=“2”
article1
return to top
(and so on and so forth)
How can I get just one title per category and one return to top per category?
Last edited by pafruu (2011-09-03 12:46:34)
I try, and I try, and I try…. and sometimes I achieve
Offline
Re: Creating a return to top links after a series of articles
Can you post how you are calling this form?
For example, what do you have in your sort
attribute for txp:article
or txp:article_custom
? That should be something like sort="category2 asc, Posted desc"
. If the articles come out not sorted by category2, if_different will be different whenever the category changes.
Second avenue, try the way shown in the post that Els linked to. Perhaps if_different also has its problems with variables. I don’t think it should make a difference but maybe:
<txp:if_different>
<!-- <txp:category2 /> -->
<txp:variable name="article_archive_different" value="yes" />
<txp:else />
<txp:variable name="article_archive_different" value="" />
</txp:if_different>
<!-- rest of your code -->
If none of that works, go back to what you tried in response to Els’ suggestion but change the end bit as follows:
<!-- rest of your code -->
<txp:if_variable name="article_archive_different" value="yes">
<div style="float:right">test 2</div>
</txp:if_variable>
<txp:if_last_article>
<div style="float:right">test 2</div>
</txp:if_last_article>
In fact, you probably don’t need the if_last_article
bit seeing as you put your “return to top” link at the end of your code block.
Last edited by jakob (2011-09-03 13:55:52)
TXP Builders – finely-crafted code, design and txp
Offline
#11 2011-09-03 15:58:04
- pafruu
- Member
- From: New Brunswick, Canada
- Registered: 2010-01-14
- Posts: 65
Re: Creating a return to top links after a series of articles
here is how I call it:
<txp:article allowoverride="1" form="ccmembres" category="membres" pgonly="0" sort="Category2 asc,Title asc" status="5" limit="999" />
I will try your suggestions and let you know if it worked
I try, and I try, and I try…. and sometimes I achieve
Offline
#12 2011-09-03 16:58:09
- pafruu
- Member
- From: New Brunswick, Canada
- Registered: 2010-01-14
- Posts: 65
Re: Creating a return to top links after a series of articles
I almost have it working:
here is the code:
<txp:if_different><txp:if_first_article><h2><a name="<txp:category2 />"><txp:category2 /></a></h2><txp:else /><h4>test 4</h4>
<h2><a name="<txp:category2 />"><txp:category2 /></a></h2></txp:if_first_article>
<txp:else />
</txp:if_different>
<--- rest of code ---->
<txp:if_last_article>
<div>test 2</div>
</txp:if_last_article>
this shows everything in its place except for the second article where the category title is repeated and the test 4 is under the first article:
you can see this at this url: http://www.rogersvillenb.com/communaute/?c=chambre
under Liste des membres
so close I can taste the sweet nectar of victory
I try, and I try, and I try…. and sometimes I achieve
Offline