Using this code to output related links works as it should:
<!-- BEGIN RELATED --> <a href="https://www.webmastersite.net/forums/WSN_Links" class="categoryname"><?php echo( str_replace('zzz ','',str_replace(' and ',' & ','{CATNAME}')) ); ?></a> <!-- END RELATED -->
I want these categories to appear as a comma delimited list. So tried this:
<?php $relcounter = 1; ?> <!-- BEGIN RELATED --> <a href="https://www.webmastersite.net/forums/WSN_Links" class="categoryname"><?php echo( str_replace('zzz ','',str_replace(' and ',' & ','{CATNAME}')) ); $relcounter += 1; if ($relcounter <= {CATNUMBERRELATED}) { echo', '; ?></a> <!-- END RELATED -->
Suddenly, instead of the related categories displaying, only the current category was output. Even the following (if I have a comma after all items) does the same:
<!-- BEGIN RELATED --> <a href="https://www.webmastersite.net/forums/WSN_Links" class="categoryname"><?php echo( str_replace('zzz ','',str_replace(' and ',' & ','{CATNAME}')) ); ?></a>, <!-- END RELATED -->
I thought the </a> might have to be the last thing so tried this:
<!-- BEGIN RELATED --> <a href="https://www.webmastersite.net/forums/WSN_Links" class="categoryname"><?php echo( str_replace('zzz ','',str_replace(' and ',' & ','{CATNAME}')) ); ?>, </a> <!-- END RELATED -->
Same problem. I can't even use <br> in there. Weird as the PHP to replace zzz (used so that misc categories appear as the last item in category lists) etc worked fine.
Moreover, I just stripped it down to:
<!-- BEGIN RELATED --> <a href="https://www.webmastersite.net/forums/WSN_Links" class="categoryname">{CATNAME}</a> <!-- END RELATED -->
and it showed the current category only. (Isn't that the default code?) Went back to the code listed first above and it worked again. Bizarre!
OK, solved own problem... if was because I had the related categories section appearing twice in the same template... once for <IF {CATLEVELSDEEP} is 0> and once otherwise. Now that I've changed this, it's fine. And for the record, the code needed to be:
<?php $relcounter = 0; $totalrel = {CATNUMBERRELATED} ?> <!-- BEGIN RELATED --> <a href="index.php?action=displaycat&catid={CATID}" class="categoryname"><?php echo(str_replace('zzz ','',str_replace(' and ',' & ','{CATNAME}'))); ?></a><?php $relcounter += 1; if ($relcounter < $totalrel) { echo(', '); } ?> <!-- END RELATED -->
0/5
1
2
3
4
5
This thread is closed, so you cannot post a reply.
Comments on Related categories - can't customize
Member
Usergroup: Customer
Joined: Feb 16, 2005
Total Topics: 4
Total Comments: 21
Using this code to output related links works as it should:
<!-- BEGIN RELATED -->
<a href="https://www.webmastersite.net/forums/WSN_Links" class="categoryname"><?php echo( str_replace('zzz ','',str_replace(' and ',' & ','{CATNAME}')) ); ?></a>
<!-- END RELATED -->
I want these categories to appear as a comma delimited list. So tried this:
<?php $relcounter = 1; ?>
<!-- BEGIN RELATED -->
<a href="https://www.webmastersite.net/forums/WSN_Links" class="categoryname"><?php echo( str_replace('zzz ','',str_replace(' and ',' & ','{CATNAME}')) ); $relcounter += 1; if ($relcounter <= {CATNUMBERRELATED}) { echo', '; ?></a>
<!-- END RELATED -->
Suddenly, instead of the related categories displaying, only the current category was output. Even the following (if I have a comma after all items) does the same:
<!-- BEGIN RELATED -->
<a href="https://www.webmastersite.net/forums/WSN_Links" class="categoryname"><?php echo( str_replace('zzz ','',str_replace(' and ',' & ','{CATNAME}')) ); ?></a>,
<!-- END RELATED -->
I thought the </a> might have to be the last thing so tried this:
<!-- BEGIN RELATED -->
<a href="https://www.webmastersite.net/forums/WSN_Links" class="categoryname"><?php echo( str_replace('zzz ','',str_replace(' and ',' & ','{CATNAME}')) ); ?>, </a>
<!-- END RELATED -->
Same problem. I can't even use <br> in there. Weird as the PHP to replace zzz (used so that misc categories appear as the last item in category lists) etc worked fine.
Moreover, I just stripped it down to:
<!-- BEGIN RELATED -->
<a href="https://www.webmastersite.net/forums/WSN_Links" class="categoryname">{CATNAME}</a>
<!-- END RELATED -->
and it showed the current category only. (Isn't that the default code?) Went back to the code listed first above and it worked again. Bizarre!
Any ideas please?
Member
Usergroup: Customer
Joined: Feb 16, 2005
Total Topics: 4
Total Comments: 21
Title of this post is wrong. I meant "related categories" of course.
Member
Usergroup: Customer
Joined: Feb 16, 2005
Total Topics: 4
Total Comments: 21
OK, solved own problem... if was because I had the related categories section appearing twice in the same template... once for <IF {CATLEVELSDEEP} is 0> and once otherwise. Now that I've changed this, it's fine. And for the record, the code needed to be:
<?php $relcounter = 0; $totalrel = {CATNUMBERRELATED} ?>
<!-- BEGIN RELATED -->
<a href="index.php?action=displaycat&catid={CATID}" class="categoryname"><?php echo(str_replace('zzz ','',str_replace(' and ',' & ','{CATNAME}'))); ?></a><?php $relcounter += 1; if ($relcounter < $totalrel) { echo(', '); } ?>
<!-- END RELATED -->