searchRows & _link

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 6, 2017   (RSS)

By petrogus - August 13, 2017

Hi All,

I create a search page with the results,

                  <?php foreach ($searchRows as $record): ?>
                     <a href="<?php echo $record['_link'] ?>"><strong><?php echo $record['_title'] ?></strong></a><br/>
                     <?php if ($record['_summary']): ?>
                       <?php echo $record['_summary'] ?><br/>
                      <?php else: ?>
                        No description available for page.<br/>
                      <?php endif ?>
                     <a href="<?php echo $record['_link'] ?>" style="color: #999;" ><?php echo $record['_link'] ?></a><br/><br/>
                  <?php endforeach ?>

and the link of the results look like as /news.php?6

but I would like to appear as /news.php?article=6

Could you help ! thank you in advance

P.

PetroGus

By Dave - August 14, 2017

Hi petrogus, 

Try replacing this: 

<a href="<?php echo $record['_link'] ?>" 

With this: 

<a href="/news.php?article=<?php echo $record['num'] ?>

Let me know if that works for you!

Dave Edis - Senior Developer
interactivetools.com

By Dave - September 6, 2017

Hi petrogus, 

I wanted to check if you got this resolved yet?  If not, let me know how you want to decide if the link is to product.php, news.php, etc.

Perhaps you have a field such as 'type' that lists the type of article then you could show the links like this: 

<?php
  $customLink = $record['_link']; // use default if no other option available
  if ($record['type'] == 'article') { $customLink = "/article.php?article=" . $record['num']; }
  if ($record['type'] == 'news')    { $customLink = "/news.php?article=" . $record['num']; }
?>

<a href="<?php echo $customLink; ?>"><strong><?php echo $record['_title'] ?></strong></a><br/>

Let me know if that works for you.

Dave Edis - Senior Developer
interactivetools.com