Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-05-25 19:11:30
- jpc8
- New Member
- Registered: 2006-05-25
- Posts: 2
permlink not working in php
I’m new to textpattern, so maybe I’m just making this harder than it needs to be, but here goes.
I’m building an online catalog (no shopping, just product listings) and I’d like to have a list of products from the same category show up in the sidebar when you’re viewing a product. So far I’m doing fine by putting a call to the following article form:
<code>
<txp:php>
if($thisarticle[‘category1’]){
echo ‘<li><span class=“permlink”>’ . $thisarticle[‘permlink’] . $thisarticle[‘title’] . ‘</a></span></li>’;
}
</txp:php>
</code>
I get the list like I want it, but the permlink doesn’t show up. I’ve also tried putting the txp tags within the echo strings, but that makes both the permlink and the title dissapear. What am I doing wrong?
Offline
Re: permlink not working in php
Your code breaks at several places.
First, there is no $thisarticle['permlink']
array member I am aware of. You will have to build a valid link by feeding $thisarticle['thisid']
into permlinkurl_id()
. Second, your markup lacks an opening a href="..."
tag.
This snippet will work:
<txp:php>
if($thisarticle['category1']){
echo '<li><span class="permlink"><a href="' . permlinkurl_id($thisarticle['thisid']) .'">'. $thisarticle['title'] . '</a></span></li>';
}
</txp:php>
From the description of what you are trying to achieve it seems that you would be better of with txp:related_articles anyway, as this tags lists all articles with matching categories. A more flexible solution would employ txp:article_custom.
Last edited by wet (2006-05-25 21:08:09)
Offline
#3 2006-05-25 22:34:51
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: permlink not working in php
See also the FAQ. It contains several recommendations for debugging PHP code.
Alex
Offline
#4 2006-05-25 22:38:15
- jpc8
- New Member
- Registered: 2006-05-25
- Posts: 2
Re: permlink not working in php
Thanks for the help, got it working. Somewhere I found a list of GLOBALS that said permlink was in the thisarticle array, must have been out of date (or just wrong).
Offline
Pages: 1