Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Break between alphabetic groups

 

 


rconring
User

Mar 19, 2009, 5:27 AM

Post #1 of 5 (1140 views)
Shortcut
Break between alphabetic groups Can't Post

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


ross
Staff / Moderator


Mar 19, 2009, 1:15 PM

Post #2 of 5 (1122 views)
Shortcut
Re: [rconring] Break between alphabetic groups [In reply to] Can't Post

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 - Product Specialist
support@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/



rconring
User

Mar 19, 2009, 4:24 PM

Post #3 of 5 (1117 views)
Shortcut
Re: [ross] Break between alphabetic groups [In reply to] Can't Post

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


Dave
Staff / Moderator


Mar 23, 2009, 9:53 AM

Post #4 of 5 (1074 views)
Shortcut
Re: [rconring] Break between alphabetic groups [In reply to] Can't Post

Hi Ron,

Try this (new code in red):


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
$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
 


rconring
User

Mar 23, 2009, 12:58 PM

Post #5 of 5 (1070 views)
Shortcut
Re: [Dave] Break between alphabetic groups [In reply to] Can't Post

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