Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-02-20 21:49:02
- azw
- Member
- Registered: 2007-01-29
- Posts: 279
How to a generic page/form to output a linklist of a category
I’m stuck (and probably confused).
I have a couple of static articles that are lists of links. What I need in the output is: a title, some text describing the list, and the list of links.
I want to create a page and a form that will allow me to output these static articles using txp’s tags.
I can hard code the title into a page by typing in a title: <h3>This is my title</h3>
, but I haven’t been able to figure out how to have a page or form add the title automatically using <txp:title />
.
Simillarly, I can hard code the text into the page and hard code the list for that specific category, <txp:linklist category="MY_SPECIFIC_CATEGORY" sort="description asc" class="list_plain" wraptag="ul" break="li" />
. But I have not figured out how to use the <txp:body />
tag to call that description or how to insert my category in the linklist tag with <txp:category />
.
Is there a way to create a generic page that can use the tags instead of hard coding?
Or should I just create a truly static page that has only one application?
Thanks!
Offline
#2 2007-02-20 22:03:10
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to a generic page/form to output a linklist of a category
Do you mean you want something like this
Title
Some text
Link category 1
- link
- link
- link
Link category 2
- link
- link
- link
etcetera.
Or:
Title for category 1
Text for category 1
- link
- link
- link
and this for each category?
Offline
#3 2007-02-20 22:40:06
- azw
- Member
- Registered: 2007-01-29
- Posts: 279
Re: How to a generic page/form to output a linklist of a category
Hi, Els, thanks for answering. I should have illustrated it like you did. No, it’s much simpler.
Title for Just one category
A paragraph or two of text for just one category.
- link
- link
- link
And nothing more. But I’d like to be able to have two different pages (with two different link categories).
Last edited by azw (2007-02-20 22:42:59)
Offline
#4 2007-02-20 23:39:13
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to a generic page/form to output a linklist of a category
Okay, the way I’d do it goes like this.
Create a section, let’s say ‘Links’.
Create two article categories with the same names as your link categories.
Write two articles in section ‘Links’, with a title and body, one for each of these two categories. Let’s say you use Category 1 for this (can of course also be Category 2).
Download and install asy_wondertag.
Create an article form, ‘links_article’ (or whatever):
<h3><txp:title /></h3>
<txp:body />
<txp:asy_wondertag><txp:linklist category="<txp:category1 />" sort="description asc" class="list_plain" wraptag="ul" break="li" /></txp:asy_wondertag>
On the page template:
<txp:if_section name="links">
<txp:if_category> <!-- if we are in section 'links' and on a category page -->
<txp:article form="links_article" limit="1" />
<txp:else /> <!-- if we are on the section 'links' homepage -->
<!-- not sure if you want something here, otherwise leave the txp:else part out -->
</txp:if_category>
</txp:if_section>
Your urls will look like site.com/links/?c=first-link-category and site.com/links/?c=second-link-category. asy_wondertag will automatically use the article’s category1 for the linklist.
The advantage of asy_wondertag is that you don’t have to use conditionals and repeat the linklist tag for every category you have (there are only two now but this will still work if you are going to add categories).
The only thing I am not 100% sure of, is if you can use txp:linklist in an article form. If not, we should be able to find a workaround.
Last edited by els (2007-02-20 23:42:58)
Offline
#5 2007-02-20 23:58:13
- azw
- Member
- Registered: 2007-01-29
- Posts: 279
Re: How to a generic page/form to output a linklist of a category
Thanks, Els. I think that’s what I was looking for.
Is there a way to make the URL be the name of the section, like this:
site.com/section_name/
There will only be one page of links in each of those sections (no other articles or pages).
Last edited by azw (2007-02-20 23:59:13)
Offline
#6 2007-02-21 00:16:17
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to a generic page/form to output a linklist of a category
I think changing my code for the page template to
<txp:if_section name="section_name1,section_name2">
<txp:article listform="links_article" limit="1" />
</txp:if_section>
should do what you want. (Mind that I’ve not tried these examples in reality, so there is a chance that I overlook something and it won’t work…)
Offline
#7 2007-02-21 00:17:29
- azw
- Member
- Registered: 2007-01-29
- Posts: 279
Re: How to a generic page/form to output a linklist of a category
Thanks, again, I’ll give it a try and let you know how it works.
Offline
#8 2007-02-21 01:52:32
- azw
- Member
- Registered: 2007-01-29
- Posts: 279
Re: How to a generic page/form to output a linklist of a category
Thanks, Els, that’s working well.
Now that I see the result, I’m wondering how to create a subtitle, just above the link list.
I’ve tried these two methods and they don’t show anything because <txp:category title="1" />
is blank. Do you have any idea of why <txp:category title="1" />
is not working?
The links page:
bc..<txp:if_section name=“conceyos”>
<txp:article listform=“linklist_article” limit=“1” />
</txp:if_section>
The linklist_article form:
Version One (using the category tag)
bc..<h3><txp:title /></h3>
<txp:body />
<h4><txp:category title=“1” /></h4>
<txp:asy_wondertag><txp:linklist category=”<txp:category />” sort=“description asc” class=“list_plain” wraptag=“ul” break=“li” /></txp:asy_wondertag>
Version Two (as part of the linklist tag)
bc..<h3><txp:title /></h3>
<txp:body />
<txp:asy_wondertag><txp:linklist category=”<txp:category />” sort=“description asc” class=“list_plain” wraptag=“ul” break=“li” label=”<txp:category title=“1” />” labeltag=“h4” /></txp:asy_wondertag>
Neither works so far.
Last edited by azw (2007-02-21 05:00:45)
Offline
#9 2007-02-21 06:16:31
- anoke
- Archived Plugin Author
- Registered: 2006-04-15
- Posts: 152
Re: How to a generic page/form to output a linklist of a category
<txp:category1 />
takes the category from the article. <txp:category />
from the currently selected (there’s ?c=catname in the url) category.
- When chickens are cold, they roost in trees; when ducks are cold, they plunge into water -
Offline
#10 2007-02-21 15:22:24
- azw
- Member
- Registered: 2007-01-29
- Posts: 279
Re: How to a generic page/form to output a linklist of a category
Thanks, Anoke.
It doesn’t work even if I give it the category name, like: <txp:category name="A_CATEGORY_NAME" />
I am using it within the sphere of an <txp:article ...
, because <txp: article ...
was called in the page, which then calls the form where I’m using <txp:category />
.
Last edited by azw (2007-02-21 15:28:22)
Offline
#11 2007-02-21 15:30:58
- azw
- Member
- Registered: 2007-01-29
- Posts: 279
Re: How to a generic page/form to output a linklist of a category
I just noticed that in this code, the category is not working, either. It prints out all of my links, which at this point are all of one category.
bc..
<txp:asy_wondertag><txp:linklist category=”<txp:category />” sort=“description asc” class=“list_plain” wraptag=“ul” break=“li” /></txp:asy_wondertag>
Offline
#12 2007-02-21 17:38:32
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How to a generic page/form to output a linklist of a category
azw
Use <txp:category1 />
instead of <txp:category />
. (txp:category1)
Last edited by els (2007-02-21 17:39:19)
Offline