Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom URL
#1
Hy

I would like add custom URL to the menu e.g. forum (/punbb) or my blog (mypage.com/blog).
how can I solve it?

Thx!

Tamás Csaba
Reply
#2
Currently, there is no standard way to add non-page links to the GetSimple menu. You could either hard-code them into the template or rewrite the template so it will redirect the visitor to a certain URL when they are on a certain page.

I was pondering over this very issue, I bet there will be a plug-in for adding links when version 2 is out. I can’t imagine only us two having this problem.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#3
I had the same issue, so I just hard-coded it into a component so that I could call it from the theme files. I know that doesn't make the most sense, but it leaves it easily editable for quick fixes.
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply
#4
I've made it simpler for users to use i guess.. still hardcoded into theme though.

New function for theme_functions.php in admin/inc/
Code:
function set_navigation_item($items, $menu, $url, $title = "url", $order = "11")
    {
        // Setting the order to last by default
        $items[] = array(
            'menu'         => $menu,
            'url'        => $url,
            'title'        => $title,
            'custom'    => true,
            'menuOrder' => $order
        );
        
        return $items;
    }

New get_navigation(); function to replace old one.
Code:
function get_navigation($currentpage, $extra = "") {
        
        global $PRETTYURLS;
        global $SITEURL;
        
        $menu = '';

        $path = "data/pages";
        $dir_handle = @opendir($path) or die("Unable to open $path");
        $filenames = array();
        while ($filename = readdir($dir_handle)) {
            $filenames[] = $filename;
        }
        
        $count="0";
        $pagesArray = array();
        if (count($filenames) != 0) {
            foreach ($filenames as $file) {
                if ($file == "." || $file == ".." || is_dir("data/pages/".$file) || $file == ".htaccess"  ) {
                    // not a page data file
                } else {
                    $thisfile = @file_get_contents('data/pages/'.$file);
                    $data = simplexml_load_string($thisfile);
                    if ($data->private != 'Y') {
                        $pagesArray[$count]['menuStatus'] = $data->menuStatus;
                        $pagesArray[$count]['menuOrder'] = $data->menuOrder;
                        $pagesArray[$count]['menu'] = stripslashes(htmlspecialchars_decode($data->menu, ENT_QUOTES));
                        $pagesArray[$count]['url'] = $data->url;
                        $pagesArray[$count]['title'] = stripslashes(htmlspecialchars_decode($data->title, ENT_QUOTES));
                        $pagesArray[$count]['parent'] = $data->parent;
                        $count++;
                    }
                }
            }
        }
        
        if($extra != ""){
            foreach($extra as $item)
            {
                $pagesArray[] = $item;
            }
        }
        
        $pagesSorted = subval_sort($pagesArray,'menuOrder');
        if (count($pagesSorted) != 0) {
            foreach ($pagesSorted as $page) {
                $sel = ''; $classes = '';
                $url_nav = $page['url'];
                
                if($page['custom']) {
                    if  ($currentpage == $url_nav) { $classes = "current"; } else { $classes = ""; }
                    $menu .= '<li class="' . $classes . '"><a href="' . $url_nav . '" title="' . $page['title'] . '">'. $page['menu'] .'</a></li>'."\n";
                } else if ($page['menuStatus'] == 'Y') {
                    if ("$currentpage" == "$url_nav") { $classes = "current ". $url_nav; } else { $classes = $url_nav; }
                    if ($page['menu'] == '') { $page['menu'] = $page['title']; }
                    if ($page['title'] == '') { $page['title'] = $page['menu']; }
                    if ($PRETTYURLS == '1') {
                        if ($page['parent'] != '' ) { $page['parent'] = tsl($page['parent']); }
                        if ($url_nav == 'index' ) { $url_nav = ''; }
                        $menu .= '<li class="'. $classes .'" ><a href="'. $SITEURL . @$page['parent'] . $url_nav .'" title="'. $page['title'] .'">'.$page['menu'] .'</a></li>'."\n";
                    } else {
                        $menu .= '<li class="'. $classes .'" ><a href="'. $SITEURL .'index.php?id='.$url_nav.'" title="'. $page['title'] .'">'.$page['menu'].'</a></li>'."\n";
                    }
                }
            }
            
            echo $menu;
        }
        
        closedir($dir_handle);
    }

Using it:
Code:
<?php
$items = set_navigation_item($items, 'twitter', 'http://twitter.com');
$items = set_navigation_item($items, 'google', 'http://google.com');
$items = set_navigation_item($items, 'top', 'top/','url',1); // menu item name, url, title, priority

get_navigation(return_page_slug(), $items);
?>

Example: http://nijikokun.com

seems pointless now after coding it D: cause hardcoding it is a lot easier.
http://nijikokun.com
random stuff. idk.
Reply




Users browsing this thread: 1 Guest(s)