searches and checkbox lists

5 posts by 3 authors in: Forums > CMS Builder
Last Post: January 31, 2012   (RSS)

Re: [rez] searches and checkbox lists

By Jason - April 27, 2011

Hi,

If you're using a newer version of CMS Builder (2.04 and up) you can make use of the pseudo fields :labels and :values.

What we'll do is first create an array of selected options with the num as the index and the title as the value. After that, we'll loop through the array and output the options in a <ul> list, with each being a link.

For example:

<?php $tags = array_combine($record['tags:values'], $record['tags:labels']); ?>

<ul>
<?php foreach ($tags as $value => $label): ?>
<li><a href="http://www.mydomain.com/tags=<?php echo $value;?>"<?php echo $label; ?></li>
<?php endforeach ?>
</ul>


Note that in this example, each link has tags= in it. This is because to do an automatic search, you need to have the name of the field appear in the url.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] searches and checkbox lists

By rez - April 28, 2011 - edited: April 28, 2011

Will google crawl these links? I see this mentioned in the documentation but it looks like the = cant be used? I tested the / situation out on my server and it works.

I'm confused though, how do i make these links in your instructions seo friendly? (I want to use all of this to build my main site navigation as well in a category menu)

Re: [rez] searches and checkbox lists

By Jason - April 28, 2011

Hi,

Yes, Google shouldn't have any trouble crawling these links. If you want to set it up to use / instead of = you could try this:

<?php $tags = array_combine($record['tags:values'], $record['tags:labels']); ?>

<ul>
<?php foreach ($tags as $value => $label): ?>
<li><a href="http://www.mydomain.com/tags/<?php echo $value;?>"<?php echo $label; ?></li>
<?php endforeach ?>
</ul>


If your server is configured correctly, this should be the same as tags=value.

Give that a try and let me know if you run into any issues.
Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] searches and checkbox lists

By Mikey - January 31, 2012

Thanks for the post Jason... I've been racking my brains over this for a few hours. Works great!