Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » <% IF $URL doesn't include 'Security' ....

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

Page: 1
Go to End
Author Topic: 879 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    <% IF $URL doesn't include 'Security' .... Link to this post

    Hi,

    I've added a log in form etc to the header of my site (munromap.co.uk) by adding $LoginForm. All good.

    However, if the user ends on original SS login page (links, incorrect password etc) then there are TWO login forms on the page - and the CSS is getting all messed up

    I would like, on the /Security/ pages, to not show the log in page in the header - not just hide it via css, but actually not show it, so there aren't duplicated bits of forms around...

    Any suggestions?

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: <% IF $URL doesn't include 'Security' .... Link to this post

    Probably best to do the logic of the if within php, rather than with the tempate...

    template.ss

    <% if SecurityLoginPage %>
    <% else %>
    //show form
    <% end_if %>

    Page.php

    function SecurityLoginPage() {
    return (strpos($_GET['url'],'Security')!==false); //note untested!
    }

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: <% IF $URL doesn't include 'Security' .... Link to this post

    Or you can use ClassName (saves adding that method)

    <% if ClassName = Security %>
    <% else %>
    ...
    <% end_if %>

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: <% IF $URL doesn't include 'Security' .... Link to this post

    Hi Willr - just tried that - sounds easier, but it made no change...

    page just putting $ClassName on the page, i saw that the 'Security' pages are simply classname 'Page'...

    so ended up using the function above - work fine...

  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Re: <% IF $URL doesn't include 'Security' .... Link to this post

    Security Pages have an ID of 0 so you could filter for if ID=0

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: <% IF $URL doesn't include 'Security' .... Link to this post

    I think you can filter on <% if URLSegment != Security %> ... <% end_if %>

    879 Views
Page: 1
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.