Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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[] = '&bull; <a href="' . $web . '">' . $sofa['name'] . ($showcount ? ' (' . $sofa['count'] . ')' : '') . '</a>';

<txp:Ruhh />

Offline

#2 2008-05-16 21:14:40

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

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[] = '&bull; <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

#4 2008-05-16 21:24:45

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: take count outside of link

You have to escape them with a period. For example, to display $count after the link:

$html[] = '&bull; <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

Board footer

Powered by FluxBB