Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-02-08 16:05:52

convoy
Member
From: Italy
Registered: 2010-02-08
Posts: 10

Handle link category from linklist in a custom form

Hi,

I have basically two categories of links to be displayed as a list in a static page but I need to display little differences according to link category.

I need to handle links from linklist like this:

In my page template I have:

<txp:linklist form="myLinkForm" category="one,two" class="myclass" limit="25" sort="date desc" wraptag="ul" break="li" />

myLinkForm would contain:

<txp:if_category name="one">
    <a href="<txp:link_url />" target="_BLANK"><txp:link_name /></a><br />
    <txp:link_description /><br />
    (..) something
</txp:if_category>
<txp:if_category name="two">
    <a href="<txp:link_url />"><txp:link_name /></a><br />
    (..) something  else
</txp:if_category>

but it doesn’t work, no category handle is passed to the form, if I put (in myLinkForm)

<txp:if_category >
     <txp:else />
      Nothing
</txp:if_category>    

I have “Nothing”..

I don’t understand if I can do it and how.
Can anybody help me ?
Thanks in advance.

Offline

#2 2010-02-08 16:30:15

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Handle link category from linklist in a custom form

Link categories are defined internal to linklist as are link descriptions, this category is not the same environmental setting as is looked at by if_category. if_category is a page template setting that linklist can’t see, so at this point the code as you have it here won’t work. This idea may make for a good feature or plugin request, perhaps an if_link_category conditional of sorts. Say along these lines plugin code_v2

	function ras_if_link_category($atts, $thing)
	{
		global $thislink;
		assert_link();
		extract(lAtts(array(
			'name' => '',
		),$atts));
	return parse(EvalElse($thing, in_list($thislink['category'] , $name)));
	}

Last edited by rsilletti (2010-02-08 17:15:49)

Offline

#3 2010-02-08 17:23:01

geroldbraun
Member
Registered: 2010-01-19
Posts: 19
Website

Re: Handle link category from linklist in a custom form

have had the problem with <txp:linklist categeory=“newsletter”> too. In linklist-tag category will not work – it always delivers empty-records (i have the feeling that linklist only accepts “sections”).

I went around it with <txp:article_custom form=“article_listing” category=“newsletter” limit=“3” />. This makes a good listing. Hope it will do the thing for you too.


Smile, Breath, Go slowly – Thich Nhat Hanh

Offline

#4 2010-02-08 17:27:27

convoy
Member
From: Italy
Registered: 2010-02-08
Posts: 10

Re: Handle link category from linklist in a custom form

Thank you for the answer,

I tried the plugin but it doesn’t seem to work properly.
Page template

<txp:linklist form="mylinkform" category="one,two" class="myclass" limit="25" sort="date desc" wraptag="ul" break="li" />

mylinkform

<txp:ras_if_link_category name="one">
     One<br/>
</txp:ras_if_link_category>
<txp:ras_if_link_category name="textpattern">
     two<br />
</txp:ras_if_link_category>
...and the <txp:link_name /><br />

it always returns to me:
one
two
..and the link

Did I use it in a wrong way?

Offline

#5 2010-02-08 17:35:11

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Handle link category from linklist in a custom form

Try version 2: plugin code_v2 the first draft would do what you described the second won’t. To answer your question, you are using it correctly.

geroldbraun linklist will see categories if they are link categories and incorporated within a linklist form, linklist has no reference to sections?

I’m testing with a tag arrangement like the following and it works well for me.

<p><txp:link /><br />
<txp:ras_if_link_category name="textpattern,linktest">
<i><txp:link_description /></i></p>
<txp:else />
<txp:link_description /></p>
</txp:ras_if_link_category>

Last edited by rsilletti (2010-02-23 17:00:25)

Offline

#6 2010-02-08 17:51:53

convoy
Member
From: Italy
Registered: 2010-02-08
Posts: 10

Re: Handle link category from linklist in a custom form

Now it works like a charm!
(I had first dumb browser’s cache problem)

Thank you very much rsilletti!

Offline

#7 2010-02-08 17:53:06

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Handle link category from linklist in a custom form

Your welcome.

Offline

#8 2010-02-08 18:01:05

geroldbraun
Member
Registered: 2010-01-19
Posts: 19
Website

Re: Handle link category from linklist in a custom form

excuse me rsilletti, my english is not the best. Just for my understanding: do you say that if i have an article-category called newsletter (for example) and have articles which are sorted in that category, then this <txp:linklist form=“Links” category=“newsletter”> will produce a list? (Provided the form Links contains something like: “<txp:link /><br /> <txp:link_description />”)

Edit: smite my forehead! You wrote link-category. i tried (and tried and tried ans so on) with article-category. Sorry for a dumb statement of mine above in my first answer here.

Last edited by geroldbraun (2010-02-08 18:21:08)


Smile, Breath, Go slowly – Thich Nhat Hanh

Offline

#9 2010-02-08 19:06:10

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: Handle link category from linklist in a custom form

Yes, article categories are set at runtime to $thisarticle[‘category1’] or 2, link categories are set to $thislink[‘category’] within a linklist form. Linklist works with $thislink, if you try to use article categories for it then the category setting is defined in $thisarticle, which linklist has no reference for. The page setting for if_category, on the other hand, uses a variable $c in the url via get. This is the difference between if_category and if_article_category. The best approach is to view it this way.

within an article form the $thisarticle array (also individual article mode) is available.
within a linklist form the $thislink array is available
also thisfile , and thiscomment arrays ect, in there appropriate form.

Last edited by rsilletti (2010-02-08 19:07:14)

Offline

Board footer

Powered by FluxBB