Zend Framework Source Code Snippets

Simple View Helper for replacing links with A HREF

Bookmark and Share
1
2
3
4
56
7
8
9
<?php
class Be_View_Helper_ClickableUris extends Zend_View_Helper_Abstract
{
    public function ClickableUris($text = '')
    {        $pattern = '#(^|[^\"=]{1})(http://|https://|ftp://|mailto:|news:)([^\s<>]+)([\s\n<>]|$)#sm';
        return preg_replace($pattern, "\\1<a href=\"\\2\\3\" target=\"_blank\"><u>\\2\\3</u></a>\\4", $text);
    }
}

Comments

You must login before commenting on a snippet. If you do not have an account, please register.

Snippet description

Replaces all "links" beginning with

http://
https://
ftp://
mailto:
news:

with a clickable link <a href="link">Link</a>

Snippet details

Created:
Ben Ben
1 year ago
Edited:
Ben Ben
1 year ago
Revision Id:
166
Edit Message:
Initial Release
ZF Version
1.10.0
Tags:
view helper view url uri
Comments:
0
Views:
3968
Points:
0 (0 votes)

History

r166

Initial Release

Ben Ben
1 year ago