Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

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

Open different template


Go to End
Reply

13 Posts   1626 Views

Avatar
steve_nyhof

5 January 2010 at 9:15pm (Last edited: 5 January 2010 9:16pm), Community Member, 224 Posts

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

Avatar
tobych

6 January 2010 at 1:18pm (Last edited: 6 January 2010 1:19pm), Community Member, 97 Posts

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

Avatar
steve_nyhof

6 January 2010 at 1:49pm (Last edited: 6 January 2010 4:55pm), Community Member, 224 Posts

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 %>

Avatar
Pigeon

6 January 2010 at 2:29pm Community Member, 243 Posts

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 :)

Avatar
steve_nyhof

6 January 2010 at 2:46pm (Last edited: 6 January 2010 2:47pm), Community Member, 224 Posts

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

Avatar
AdamJ

6 January 2010 at 3:03pm Community Member, 145 Posts

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

Avatar
steve_nyhof

6 January 2010 at 3:33pm Community Member, 224 Posts

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.

Avatar
AdamJ

6 January 2010 at 3:48pm Community Member, 145 Posts

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.

Go to Top