PDA

View Full Version : Category Display Parsing


MadZebra
11-21-2007, 06:22 PM
I'm trying to customize the output of the [categories] display. I just want it to display the selection, not the actual category. For example, I have a selection named Youth Events under the category of Display Categories. When I parse [categories] is comes out as Display Categories: Youth Events.

I've tried leaving the category name blank. When I do this, it parses as : Youth Events. I just want is to say Youth Events with no extra text. Any suggestions?

ve9gra
11-22-2007, 06:21 AM
It is not possible to actually modify the code that generates it, but with some crafty PHP, you can modify it after the fact.

Name your category with some weird characters like §¶£¤³ and make sure that it outputs properly in the HTML (not like &).

On the page where you're displaying your list, you'll need to use output buffering. So, in your $LIST section, this is how you'll want to have it.
$LIST=1;
[all of your options]
ob_start();
require("calendar/calendar.php");
$epcListOutput=ob_get_clean();

So, now we have the list output saved into a variable. We can now use the PHP text functions to go in a strip out what we don't want and then display the modified version. For this example, we'll say that you did name your category "§¶£¤³".
$epcListOutput=ereg_replace("§¶£¤³: ", "", $epcListOutput);
echo $epcListOutput;
Note that the text you're looking for is the name of the category, plus ": " because you also want to remove the colon and the space.

MadZebra
11-22-2007, 01:35 PM
Thanks for the quick reply. After a little tweaking, I got the output to come out the way I wanted it to. One minor tweak was needed to get this working. Your code:

$epcListOutput=ereg_replace("§¶£¤³: ", "", $epcListOutput);
echo $epcListOutput;

Should read:
$epcListOutput=ereg_replace("§¶£¤³:", "", $epcListOutput);
echo $epcListOutput;

The space after the colon was throwing everything off. For those who are looking to do this, the random characters aren't needed for this to work, you just want to make sure that your new category name is unique and not "category."