Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Blog in menu
#1
I'd like to add a blog to my GetSimple site (1sthope.org.uk), but don't want to complicate the code. I've created a blog using a different system at blog.1sthope.org.uk and I'd like to add this as a menu item on my main site, but for the life of me I can't think how to do that. I'd be grateful for any pointers.
Reply
#2
Thanks for giving me time to think about it. I've just put the navigation I wanted into the template, which was a perfectly obvious thing to do.
Reply
#3
A way to do what you asked for, by patching GS:

- First create a new page. In this example, its slug should be 'blog'. Check 'Add to menu'
- Edit admin/inc/basic.php
- In line 295, insert:

Code:
if ($slug == 'blog') $url = 'http://blog.1sthope.org.uk';

Dynamically generated menus like the one included with GS or other like Zegnat's Multilevel would display this custom link.

Important note: This is for GetSimple 2.01 -- not valid for 2.0 or older versions (which didn't use the patched find_url() function)
Reply
#4
That's great - very elegant.
I'll be doing that,
Reply
#5
It works very nicely.
But how do i add two (or more) menu items this way. I supose it must be simple but i'm not realy a hero in php.

Thanks in advance
_
Silence Is The True Friend That Never Betrays
Reply
#6
Not tested, but should work:
Code:
switch ($slug) {
    case 'blog1':
        $url = 'http://first_blog_address';
        break;
    case 'blog2':
        $url = 'http://second_blog_address';
        break;
    case 'blog3':
        $url = 'http://third_blog_address';
        break;
}

Add as many "case ... break;" blocks as you need.

Just like my previous example, insert the code almost at the end of /admin/inc/basic.php, just BEFORE this line:
Code:
return $url;

(Line 295 in GS 2.01; around 348 or so in beta 2.02...)

Edit: Of course, you have to create in GetSimple pages with slugs blog1, blog2 and blog3 -or whatever name you want-. No need to put content in those, it won't be displayed.
Reply
#7
Sweet! Works like a dream.

Thanks
_
Silence Is The True Friend That Never Betrays
Reply
#8
I can think of another -similar- way of doing this without patching GS, but with a plugin.

However, it would have a drawback (though 'normal' users would not notice it): URLs of menu links would be GetSimple's original ones. Once you click on them you'd be redirected to the 'external' (blog or whatever) pages.
Reply
#9
Well, actually this a good way for me because i personaly don't really need links to an external site. I want to have menu items for a flash gallery i want to use, where you can use 'sort of' permalinks thru actionscript, something like:
Code:
portfolio#num=0&id=albumname
But i want to keep the portfolio page too, like having the cake and eat it Smile. I've tried some other ways but actionscript/flash seems to be pritty picky due to securitysettings. And this is working well for me, so im going to stick with it.

If you can think of another better way, post it. I think others will find a good use for it.
_
Silence Is The True Friend That Never Betrays
Reply
#10
By 'external' I meant any URL that is not a GetSimple-generated page, be it in the same server/site or in another.
Reply
#11
phillphorrari Wrote:If you can think of another better way, post it. I think others will find a good use for it.

This other way would be a very simple plugin that adds a field to GS page options called "Redirect to URL:". The plugin would use hook 'index-pretemplate': before rendering the page, if the RedirectTo field is not empty, it would do a 301 redirect to the (URL) value.

This way you would not need to patch the core. But however, as I said, links in the menu would still be GetSimple URLs.
Reply




Users browsing this thread: 1 Guest(s)