Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Absolute URLS

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1 2
Go to End
Author Topic: 5240 Views
  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Absolute URLS Link to this post

    Hi,

    It would be nice to add an absolute/relative URL switch to the CMS (the menu for example now generates relative URL's which , according to some SEO companies , is bad for google).

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Absolute URLS Link to this post

    i thing having "one switch" would be way to global - we deal with this on a case-by-case basis. you can easily transform back and forth between relative and absolute using the Director-class.
    if by "the menu" you mean the <% control Menu(1) %> in your template - no problem, just use $BaseUrl $Link.
    for the data-types "Text" and "HTMLText", theres a function AbsoluteLinks().
    usage in your template for example: $Content.AbsoluteLinks

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: Absolute URLS Link to this post

    Agreed. ;-)

    Thanks for clearing that up !

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: Absolute URLS Link to this post

    Hi Ingo,

    $BaseUrl is empty here ?

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: Absolute URLS Link to this post

    Hi Ingo,

    I can't figure this out. The BaseUrl variable returns empty here?

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Absolute URLS Link to this post

    sorry, it should read $BaseHref

  • Fuzz10
    Avatar
    Community Member
    786 Posts

    Re: Absolute URLS Link to this post

    Thanks for your quick reply.

    Forgive me for asking silly questions , but how do I concatenate these two strings in the template ($BaseHref and $Link) in such a way it produces a valid URL. I end up with one slash too much. ;-)

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Absolute URLS Link to this post

    lol sorry to put you on a wild-goose-chase here, i didn't really see the obvious:
    there's a property $AbsoluteLink in sapphire/core/model/SiteTree.php (the parent-class of every Page-object).

    5240 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.