hyphen

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 6, 2011   (RSS)

By Toledoh - July 5, 2011

Hi Guys.

I'm trying to add the following code;
workshopsDetail.php?title=$group

And this generates:

workshopsDetail.php?title=getting started, but I need it to show the hypens... workshopsDetail.php?title=getting-started

any ideas?
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] hyphen

By Dave - July 5, 2011

Hi Tim,

Are you sure you don't want it urlencoded? Such as:

workshopsDetail.php?title=<?php echo urlencode($group); ?>

Or:
<?php echo "workshopsDetail.php?title=" .urlencode($group); ?>

Let me know if that works, or if you really do want hyphens.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] hyphen

By Toledoh - July 5, 2011

Hi Dave,

The complete bit of code is actually <?php
$old_group = ''; // init blank var.
foreach ($eventsRecords as $record):
$group = $record['workshop:label']; // load sub-group value from record.
if ($group != $old_group) { // If different from the last sub-group value, print the sub-group name.
echo "<a href='$group'><h2>$group</h2></a>";
}?>
How do I use urlencode there?
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] hyphen

By Toledoh - July 5, 2011

Got it!
<?php
$old_group = ''; // init blank var.
foreach ($eventsRecords as $record):
$groupnum = $record['workshop']; // load sub-group value from record.
$group = $record['workshop:label']; // load sub-group value from record.
if ($group != $old_group) { // If different from the last sub-group value, print the sub-group name.
echo "<a href='workshopsDetail.php?title=".urlencode($groupnum)."'><h2>$group</h2></a>";
}?>


Thanks!
Cheers,

Tim (toledoh.com.au)