Link to related items with checkboxes

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 23, 2013   (RSS)

By gregThomas - May 23, 2013

Hi Tim,

If you're using the services num field for the value in the list field in the portfolio section, then this should work:

  $services = array_combine($record['services:values'], $record['services:labels']);

?>
<?php foreach ($services as $key => $service): ?>
  <a href='services.php?<?php echo urlencode($service).'-'.$key; ?>'><span class='sm<?php echo $service; ?>'></a></span>
<?php endforeach ?>

You should just be able to swap the code in your post for the code in this post. But this is example code, so you might have to make a few changes to get it working.

So the array_combine function creates an array where the values in the service field are used for the keys, and the labels are used for the values. Then I've modified your code so that the foreach loop cycles through the services array and creates a link to the correct services page using the key and value. The url encode function ensures that any special charters or spaces get converted for use in a URL. 

Let me know if you have any questions.

Thanks

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Toledoh - May 23, 2013

copy and pasted - works perfectly.  Thanks Greg!

Cheers,

Tim (toledoh.com.au)