Forums » Themes and Public Display

link_href Helper Function

(2 posts)
  • Started 2 months ago by kyleroth
  • Latest reply from KrisKelly
  1. 2 months ago # | |

    I added a function called link_href to ../helpers/Functions.php and it allows me to link image buttons to item pages. Is there a better way to code this with one of the current functions or would this be something beneficial to add to the global Functions page?

    Code in Functions.php:

    function link_href($record, $action='show', $text) {
    $path = $record->getPluralized() . DIRECTORY_SEPARATOR . $action . DIRECTORY_SEPARATOR . $record->id;
    return '<a href="'. uri($path) . '">' . ($text) . '</a>';
    }

    Code on frontend:

    <?php $orangebot = img('orange-btn.gif'); ?>
    <?php echo link_href($featuredItem,show,"<img src=$orangebot border='0' >"); ?>

    You can see the theme that I am developing here: http://euclidcorridor.dreamhosters.com/

  2. 2 months ago # | |

    Yes, there is already a link_to() function that does what your function does for most cases. You can't use it for inserting HTML into the tag, so there will probably be a link_to_img() helper that does something similar to what yours does. I would imagine that it would be something like: link_to_img($featuredItem, 'show', 'orange-btn.gif');. By the way, nice job on the that theme, it looks great!

RSS feed for this topic

Reply

You must log in to post.