Break between alphabetic groups

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

By rconring - March 19, 2009

Being new to PHP, I am having a bit of a problem forcing a line or double break between sections in an alphabetized list of links to other sites. I don't know the syntax for doing this based on first character change. I did a temporary workaround by using a line_after checkbox on each entry and if true, printing a line:
<?php foreach ($listRows 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" style="color: #CC3300">
<?php endif ?>
<?php endforeach ?>
I have done this in other languages ... just PHP challenged. It has to be simple.

Your help would be appreciated.
Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

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: [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