Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-05-21 12:32:17

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: Dictating category links order

jsoo wrote:

… Only reasonable solutions I can see are my first suggestion or making an article_custom plugin to handle this situation.

The sad thing is that i didn’t understand solution or what a article_custom plugin in fact is :-/

I’ve come up with another approach:-

    <txp:if_article_category name="promise" >
	<txp:variable name="my_var_volgorde" value="<txp:custom_field name='aanverwante_links_volgorde'>" />
	<txp:smd_if field="txpvar:my_var_volgorde" operator="isused">
 	   <txp:article_custom form="MTS_article_list" sort="custom_3 asc" category="promise" aanverwante_links_volgorde="{isused}" offset="0" />
	</txp:smd_if>
    </txp:if_article_category>

What i am trying to do is get the custom_field value as a variable, compare that value to with “{isused}” and if it’s true output only those articles. But I can’t get the variable be parsed by the custom_field attribute name.


I think, therefore I AM, … … er … I think :-?

Offline

#14 2009-05-21 12:42:30

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Dictating category links order

Try this:

<txp:php>
$c1 = $thisarticle['category1'];
$c2 = $thisarticle['category2'];
$rs = safe_rows('ID, Title', 'textpattern', "custom_3 != '' and ((Category1 = '$c1') or (Category1 = '$c2') or (Category2 = '$c1') or (Category2 = '$c2')) order by custom_3 asc");
foreach ( $rs as $r )
echo href($r['Title'], permlinkurl_id($r['ID'])) .'<br />';
</txp:php>

(Oops — edited)

Last edited by jsoo (2009-05-21 12:48:09)


Code is topiary

Offline

#15 2009-05-21 13:10:58

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: Dictating category links order

That’s nearly there ;-) That is what i am trying to achieve with textpattern tags.

The only thing it’s missing is that the links need to wrap and break using a parent <li> instead of <br />. And I need to offset by 1 link (as i don’t need to show this).
I removed the references to Category1 on line three, as I use this for the parent category.

$c1 = $thisarticle['category1'];
$c2 = $thisarticle['category2'];
$rs = safe_rows('ID, Title', 'textpattern', "custom_3 != '' and ((Category2 = '$c1') or (Category2 = '$c2')) order by custom_3 asc");
foreach ( $rs as $r )
echo href($r['Title'], permlinkurl_id($r['ID'])) .'<br />';
</txp:php>

Last edited by Timid&friendly (2009-05-21 13:13:48)


I think, therefore I AM, … … er … I think :-?

Offline

#16 2009-05-21 13:58:21

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Dictating category links order

This works for me (on the page). Keep in mind that the code is using my own section and custom field names. The if_article_category part is only to be able to use both categories, if you don’t need that you can remove it.

<txp:if_individual_article>
	<h3>Related articles</h3>
	<ul>
	<txp:article_custom sort="custom_4 asc" section="zoo" category='<txp:category1 /><txp:if_article_category number="2">,<txp:category2 /></txp:if_article_category>'>
		<txp:if_article_id>
		<txp:else />
			<txp:if_custom_field name="sortfield">
				<li><txp:permlink><txp:title /></txp:permlink></li>
			</txp:if_custom_field>
		</txp:if_article_id>
	</txp:article_custom>
	<txp:article_custom section="zoo" sortfield="" category='<txp:category1 /><txp:if_article_category number="2">,<txp:category2 /></txp:if_article_category>'>
		<txp:if_article_id>
		<txp:else />
			<li><txp:permlink><txp:title /></txp:permlink></li>
		</txp:if_article_id>
	</txp:article_custom>
	</ul>
</txp:if_individual_article>

Last edited by els (2009-08-08 12:29:10)

Offline

#17 2009-05-21 16:03:52

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: Dictating category links order

Once again thx for all your input. Ik works 99%

This is what i now have.

				<txp:article_custom offset="1" sort="custom_3 asc" category='<txp:category2 />'>
					<txp:if_custom_field name="aanverwante_links_volgorde">
						<li><txp:permlink><txp:title /></txp:permlink></li>
					</txp:if_custom_field>
				</txp:article_custom>
				<txp:article_custom sort="posted asc" aanverwante_links_volgorde="" category='<txp:category2 />'>
					<li><txp:permlink><txp:title /></txp:permlink></li>
			        </txp:article_custom>

The one thing that’s not working 100% is when there are unsorted articles, the offset no-longer works on the sorted articles??????

Last edited by Timid&friendly (2009-05-21 16:04:11)


I think, therefore I AM, … … er … I think :-?

Offline

#18 2009-05-21 16:10:26

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Dictating category links order

offset="1" sort="custom_3 asc" will skip the first article in the list generated by the tag and it’s attributes, in this case the article with the lowest value in custom_3. Are you using the offset to exclude the current article? Why not use my if_article_id method?

Offline

#19 2009-05-21 16:15:10

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Dictating category links order

Timid&friendly wrote:

The one thing that’s not working 100% is when there are unsorted articles, the offset no-longer works on the sorted articles??????

Right, because the conditional is inside the article tag; the tag itself is picking up all the articles.

There’s probably a native tag-based solution in which the offset is the count of the unsorted articles plus one.


Code is topiary

Offline

#20 2009-05-21 16:30:28

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Dictating category links order

Timid&friendly wrote:

The only thing it’s missing is that the links need to wrap and break using a parent <li> instead of <br />. And I need to offset by 1 link (as i don’t need to show this).

<ul>
<txp:php>
$c1 = $thisarticle['category1'];
$c2 = $thisarticle['category2'];
$rs = safe_rows('ID, Title', 'textpattern', "custom_3 != '' and ((Category2 = '$c1') or (Category2 = '$c2')) order by custom_3 asc limit 1,999");
foreach ( $rs as $r )
echo tag(href($r['Title'], permlinkurl_id($r['ID'])), 'li');
</txp:php>
</ul>

Code is topiary

Offline

#21 2009-05-21 16:46:58

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: Dictating category links order

Els wrote:

…Are you using the offset to exclude the current article?

No i am not. (btw. i am gunna stop saying thx cos you know i am ;-)
The purpose of the offset is to hide the first article in my level2 navigation, which has category names “wat” and “promise”.
The level3 navigation is what i am trying to output, which only has the category name “promise”.

This first ordered article needs to be skipped so that is doesn’t appear in level3 nav (this level2 nav item has to have the level3 category name “promise” otherwise it won’t show them).

I love txp but navigation can be real drama some times :-( and as far as i am concerned it’s certainly not intuitive.

Last edited by Timid&friendly (2009-05-21 16:52:03)


I think, therefore I AM, … … er … I think :-?

Offline

#22 2009-05-21 17:39:58

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Dictating category links order

Timid&friendly wrote:

(btw. i am gunna stop saying thx cos you know i am ;-)

Fine :) It’s more important to me to hear if my contributions work or not.

The purpose of the offset is to hide the first article in my level2 navigation, which has category names “wat” and “promise”.
The level3 navigation is what i am trying to output, which only has the category name “promise”.

So I misunderstood what you were using ‘offset’ for. Would excluding category ‘wat’ do the same?

BTW I’m not sure if I should still be replying ;) Are you working with jsoo’s examples or mine?

Offline

#23 2009-05-21 20:03:37

Timid&friendly
Member
From: The Netherlands
Registered: 2006-05-28
Posts: 252
Website

Re: Dictating category links order

Your replies are always very welcome. I am trying to really understand txp so i am trying everything, your suggestions and those kindly offered by jsoo’s. I want to master this CMS so i can do anything i need to or want, but i’ve still got a long way to go.

Excluding the category “wat” may indeed help. But i already looked to see if exclude was an attribute of the article_custom tag and it wasn’t.
I was thinking about adding classes “level1, level2 and 3” so as to avoid these sorts of conflicts i have ran into. I’ve heard there’s a plug-in that gives you unlimited categories.

It would however be very handy if txp it’s self had extra nav functionality, something like the category/section select pulldowns but for navigation allone, that allow one to specify structurally and sematically the role of articles within the system. … but i’ll guess i’ll just try the extra categories first ;-)


I think, therefore I AM, … … er … I think :-?

Offline

#24 2009-05-21 20:08:57

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Dictating category links order

A ‘workaround’ to exclude a category is this:

<txp:article_custom sort="custom_3 asc" category='<txp:category2 />'>
	<txp:if_article_category name="wat">
	<txp:else />
		<txp:if_custom_field name="aanverwante_links_volgorde">
			<li><txp:permlink><txp:title /></txp:permlink></li>
		</txp:if_custom_field>
	</txp:if_article_category>
</txp:article_custom>

Offline

Board footer

Powered by FluxBB