Jump to:

23379 Posts in 18298 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Open different template

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1 2
Go to End
Author Topic: 1492 Views
  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Open different template Link to this post

    I know I seen something somewhere on this. I want to open the content from Page.ss into a different PagePopup.ss

    I have the page types made, I am looking to view the same content on the Page.ss in the site, but if the setup is different, I want to call up the content into PagePopup.ss

    Any ideas? Some type of URL code in the http://...

    I found this, don't understand
    http://www.silverstripe.org/archive/show/79233#post79233

    Please help
    Thank you,
    Steve

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: Open different template Link to this post

    As explained here:

    http://doc.silverstripe.org/doku.php?id=built-in-page-controls

    you can view data from another page using the Page control. It takes a URLSegment (eg home or my-page):

    <% control Page(my-page) %>
    $Content
    <% end_control %>

    Hope this helps.

    Toby

  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Re: Open different template Link to this post

    Hi Toby,

    I'm still not getting how to do this.

    I have the page types made, I am looking to view the same content on the Page.ss in the site, but if the setup is different, I want to call up the content into PagePopup.ss

    Can you explain a little more based on what I am trying to do here please?

    I have a site that will navigate normally with navigation buttons. At the bottom are the disclaimer links. These links open up their content on Page.ss. All good.

    However, there is an option I have setup that allow the user to remove the navigation to generate a one page capture page if they like. The disclaimers links are still in place, but because I do not want to show navigation, I have made another page PagePopup.ss which does not include navigation.

    When the user chooses the option to have no navigation, I have an if statement in the Page.ss file to one set of hrefs or another set with javascript popups. I am hoping to open the popups into PagePopup.ss. I have this done... see below.

    I hope this helps, but I am not understanding the URLSegment or how it is used to get what I am after here.

    Thank you,
    Steve

    <% if ShowMyFooter %>
    <div>$callSocialScripts.SocialScripts</div>
    <div class="typography">$callGlobalFooter.MyFooter</div>
    <% end_if %>

    <% if ShowFootNav %>
    <div id="disclaimer"><a href="disclaimer/" target="_top">Disclaimer</a> <span style="color:#666;">|</span> <a href="terms-of-use/" target="_top">Terms of Use</a> <span style="color:#666;">|</span> <a href="income-disclaimer/" target="_top">Income Disclaimer</a> <span style="color:#666;">|</span> <a href="privacy-policy/" target="_top">Privacy Policy</a></div>
    <% else %>
    <div id="disclaimer">

    <a href="disclaimer/?t=12" onclick="javascript:void window.open('disclaimer','1262634071452','width=860,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1');return false;">Disclaimer</a> <span style="color:#666;">|</span> <a href="terms-of-use/" onclick="javascript:void window.open('terms-of-use/','1262634071452','width=860,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1');return false;">Terms of Use</a> <span style="color:#666;">|</span> <a href="income-disclaimer/" onclick="javascript:void window.open('income-disclaimer/','1262634071452','width=860,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1');return false;">Income Disclaimer</a> <span style="color:#666;">|</span> <a href="privacy-policy/" onclick="javascript:void window.open('privacy-policy/','1262634071452','width=860,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1');return false;">Privacy Policy</a></div>
    <% end_if %>

  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: Open different template Link to this post

    Hey Steve,

    I think i know what you are getting at.

    You basically just need to set a function in your controller so that if you were to go to http://example.com/URLSegment/popup/ then it uses a different Layout file.

    This is usually used for ajax calls and the like, but is equally suited to pop-ups.

    In Page_Controller

    function popup() {
    return $this->renderWith('TemplateName');
    }


    http://doc.silverstripe.org/doku.php?id=templates#calling_templates_from_php_code might help too.

    The ajax recipe *might* help a little too: http://doc.silverstripe.org/doku.php?id=recipes:ajax_basics

    Enjoy

  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Re: Open different template Link to this post

    I'm very sorry, but I am not following. I have read the doc, but I have a thick head, takes me forever to get it. Once things work I can see why, but I am only now getting into the deeper things that SS offers.

    In Page_Controller

    function popup() {
    return $this->renderWith('PagePopup');
    }

    Like this...

    class Page_Controller extends ContentController {

       public function init() {
          parent::init();

          // Note: you should use SS template require tags inside your templates
          // instead of putting Requirements calls here. However these are
          // included so that our older themes still work
          Requirements::themedCSS("layout");
          Requirements::themedCSS("typography");
          Requirements::themedCSS("form");
          
       }
       
       
       function popup() {
       return $this->renderWith('PagePopop');
       }
       

    How do I call it at the href ?

    Please help. this is one of the last things I need to complete to get this out.

    Thank you,
    Steve

  • AdamJ
    Avatar
    Community Member
    145 Posts

    Re: Open different template Link to this post

    Steve, if you have it setup like you showed, and its on your home page that your doing this, then, try going to yoursite.com/home/popup

  • steve_nyhof
    Avatar
    Community Member
    224 Posts

    Re: Open different template Link to this post

    I think I am getting it to work. Not like I was after, but I think I am beginning to understand by your small comment. I will press on.

  • AdamJ
    Avatar
    Community Member
    145 Posts

    Re: Open different template Link to this post

    If its in the page controller, you should be able to do it for any page (if thats what your after) by just putting "/popup" after the URLsegment of each page.

    1492 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.