Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2008-05-16 20:09:32
- Ruhh
- Member
- From: dakota dunes
- Registered: 2008-01-20
- Posts: 305
take count outside of link
Looking at this code below, how do I take the count outside of the link without making any errors?
$html[] = '• <a href="' . $web . '">' . $sofa['name'] . ($showcount ? ' (' . $sofa['count'] . ')' : '') . '</a>';
<txp:Ruhh />
Offline
Re: take count outside of link
/*
If you don't need the parentheses, just insert $sofa['count'] wherever
you need it. Otherwise, use $count.
*/
$count = ($showcount ? ' (' . $sofa['count'] . ')' : '');
$html[] = '• <a href="' . $web . '">' . $sofa['name'] . '</a>';
Offline
#3 2008-05-16 21:20:42
- Ruhh
- Member
- From: dakota dunes
- Registered: 2008-01-20
- Posts: 305
Re: take count outside of link
I don’t understand…
When I add $sofa[‘count’] after the </a> tag, I get errors.
Or when I add $count after the </a> tag, I see $count.
EDIT: Ok, I had to use (’ . $sofa[‘count’] . ‘) not $sofa[‘count’].
Last edited by Ruhh (2008-05-16 21:24:19)
<txp:Ruhh />
Offline
Re: take count outside of link
You have to escape them with a period. For example, to display $count
after the link:
$html[] = '• <a href="' . $web . '">' . $sofa['name'] . '</a> '. $count;
Offline
#5 2008-05-16 21:27:18
- Ruhh
- Member
- From: dakota dunes
- Registered: 2008-01-20
- Posts: 305
Re: take count outside of link
Oh right. I am in the process of learning PHP. Doh me!
<txp:Ruhh />
Offline
Pages: 1