Beispiel #1
0
/**
 * Smarty {url} function plugin
 *
 * Type:     function<br>
 * Name:     url<br>
 * Purpose:  returns the friendlyurl<br>
 * @author Nathan Gardner <*****@*****.**>
 */
function smarty_function_url($params, &$smarty)
{
    $objUrl = new FriendlyurlModel();
    if (!empty($params['identifier'])) {
        if (!empty($params['type'])) {
            switch ($params['type']) {
                case 'page':
                    $table = 'pages';
                    break;
                case 'blog-category':
                    $table = 'blog_categories';
                    break;
                case 'blog-article':
                    $table = 'blog_articles';
                    break;
                default:
                    $table = 'pages';
                    break;
            }
        } else {
            $table = 'pages';
        }
        $url = $objUrl->findUrl($table, $params['identifier']);
        return $url;
    } else {
        return 'Must pass an identifier';
    }
}
Beispiel #2
0
function smarty_function_menu_makemenu($pageList, &$output = '', &$smarty)
{
    $objUrl = new FriendlyurlModel();
    $output .= '<ul>';
    foreach ($pageList as $page) {
        if (!empty($page['active'])) {
            $class = ' class="active"';
        } else {
            $class = '';
        }
        $output .= '<li' . $class . '>';
        if ($page['type'] == 'page') {
            $url = $objUrl->findUrl('pages', $page['keyName']);
        } else {
            $url = $page['url'];
        }
        $output .= '<a href="' . $url . '" target="' . $page['windowaction'] . '">' . $page['title'] . '</a>';
        if (!empty($page['children'])) {
            smarty_function_menu_makemenu($page['children'], $output, $smarty);
        }
        $output .= '</li>';
    }
    $output .= '</ul>';
    return $output;
}