Gdn_Theme::logo PHP Method

    public static function logo($Properties = array())
    {
        $Logo = c('Garden.Logo');
        if ($Logo) {
            // Only trim slash from relative paths.
            if (!stringBeginsWith($Logo, '//')) {
                $Logo = ltrim($Logo, '/');
            }
            // Fix the logo path.
            if (stringBeginsWith($Logo, 'uploads/')) {
                $Logo = substr($Logo, strlen('uploads/'));
            }
            // Set optional title text.
            if (empty($Properties['title']) && c('Garden.LogoTitle')) {
                $Properties['title'] = c('Garden.LogoTitle');
            }
        }
        // Use the site title as alt if none was given.
        $Title = c('Garden.Title', 'Title');
        if (empty($Properties['alt'])) {
            $Properties['alt'] = $Title;
        }
        echo $Logo ? Img(Gdn_Upload::url($Logo), $Properties) : $Title;
    }

Usage Example

示例#1
0
/**
 * Writes the site logo to the page.
 *
 * @param array $Params The parameters passed into the function.
 * @param Smarty $Smarty The smarty object rendering the template.
 * @return The HTML img tag or site title if no logo is set.
 */
function smarty_function_logo($Params, &$Smarty)
{
    $Options = array();
    // Whitelist params to be passed on.
    if (isset($Params['alt'])) {
        $Options['alt'] = $Params['alt'];
    }
    if (isset($Params['class'])) {
        $Options['class'] = $Params['class'];
    }
    if (isset($Params['title'])) {
        $Options['title'] = $Params['title'];
    }
    if (isset($Params['height'])) {
        $Options['height'] = $Params['height'];
    }
    if (isset($Params['width'])) {
        $Options['width'] = $Params['width'];
    }
    $Result = Gdn_Theme::logo($Options);
    return $Result;
}