Break between alphabetic groups

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 23, 2009   (RSS)

Re: [rconring] Break between alphabetic groups

By ross - March 19, 2009

Hi Ron

Thanks for posting!

How are you entering the links into your system? Is it one article for each link?

Could you send me a link of the page you are working on?

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Break between alphabetic groups

By rconring - March 19, 2009

Ross ...

Thanks for your response. This is a "Links to Others" page ... simply a page dedicated to Gratefule Dog Bakery's patrons and business friends. All I am trying to accomplish is to separate the alphabetic title groups with a space or line for readability. I need the php logic to detect the first character change in the title. and print a line. I am currently forcing a line if the records "line_after" field is checked. The record consists of 4 fields, link text (title), web URL, rollover text, and line_after checkbox.
Here is the display code:
<?php foreach ($linksRecords as $record): ?>
<a target="_blank" title="<?php echo $record['screen_tip'] ?>" href="<?php echo $record['web_address'] ?>"><?php echo $record['title'] ?></a>
<br />
<?php if ($record['line_after'] == '1'): ?>
<hr width="50%" size="1">
<?php endif ?>
<?php endforeach ?>

Resulting this page: http://gratefuldogbakery.com/links.php
Thanks, Ross
Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

Re: [rconring] Break between alphabetic groups

By Dave - March 23, 2009

Hi Ron,

Try this (new code in red):

<?php foreach ($linksRecords as $record): ?>
<a target="_blank" title="<?php echo $record['screen_tip'] ?>"
href="<?php echo $record['web_address'] ?>"><?php echo $record['title'] ?></a><br />

<?php
$letter = substr($record['title'], 0,1);
if ($letter != @$lastLetter) { print '<hr width="50%" size="1">'; }
$lastLetter = $letter;
?>


<?php endforeach ?>


Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Break between alphabetic groups

By rconring - March 23, 2009

Dave ....
Thanks so much for your reply. The code worked like a champ. I added it to my collection of " Snippets for the PHP challenged". I ended up placing the code BEFORE the link and printing a break rather than a line. Looks better and works fine.

Thanks again for perfectly awsome support!!
Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987