Welcome Guest, Not a member yet? Register   Sign In
new simple function for URI class
#1

[eluser]Iverson[/eluser]
I run multiple applications for separate clients on one CI install. However, I still want them to be able to access my top level domain so I created a simple function almost identical to site_url();

In your application/config.php, add

Code:
// Add the trailing slash!
$conf['top_url'] = 'http://example.com/';

In <b>url_helper.php</b>, add

Code:
/**
* Top URL
*
* Returns the "top_url" item from your config file
*
* @access    public
* @return    string
*/
if ( ! function_exists('top_url'))
{
    function top_url($uri = '')
    {
        $CI =& get_instance();
        return $CI->config->item('top_url') . $uri;
    }
}

// ------------------------------------------------------------------------

Now all you have to do is call "top_url()" and it'll take you to your top level domain. Might not be useful for others, but I figured I'd share it anyway. Suggestions welcome.
#2

[eluser]xwero[/eluser]
I did a similar function that requires no additional config setting
Code:
function domain($url='')
{
    $parts = parse_url(config_item('base_url'));
    $return = $parts['scheme'].'://'.$parts['host'];
    if( ! empty($url)){ $return .= '/'.$url; }
    return $return;
}
#3

[eluser]Iverson[/eluser]
Sweet! Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB