Welcome Guest, Not a member yet? Register   Sign In
Small fix for CI documentation/URL Helper
#1

[eluser]Carlos Mora[/eluser]
In function anchor(), the first example states :

----8<----------------------
Code:
echo anchor('news/local/123', 'title="My News"');

Would produce: <a href="http://example.com/index.php/news/local/123" title="My News">My News</a>
----8<----------------------

the second parameter "My News" is missing to get that result. The current code produces
Code:
<a href="https://saturno/listin.php/news/local/123">title="My News"</a>

Regards,

Carlos
#2

[eluser]sophistry[/eluser]
yes, good catch, this is a bug in the documentation.

the example code needs a second parameter to be a string specifying the text that will appear inside the a tags.

check this CI URL helper code and see if you can spot why the example is wrong:
Code:
/**
* Anchor Link
*
* Creates an anchor based on the local URL.
*
* @access    public
* @param    string    the URL
* @param    string    the link title
* @param    mixed    any attributes
* @return    string
*/
if ( ! function_exists('anchor'))
{
    function anchor($uri = '', $title = '', $attributes = '')
    {
        $title = (string) $title;

        if ( ! is_array($uri))
        {
            $site_url = ( ! preg_match('!^\w+://! i', $uri)) ? site_url($uri) : $uri;
        }
        else
        {
            $site_url = site_url($uri);
        }

        if ($title == '')
        {
            $title = $site_url;
        }

        if ($attributes != '')
        {
            $attributes = _parse_attributes($attributes);
        }

        return '<a href="'.$site_url.'">'.$title.'</a>';
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB