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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Open different template


Go to End


13 Posts   2493 Views

Avatar
steve_nyhof

Community Member, 224 Posts

5 January 2010 at 9:15pm

Edited: 05/01/2010 9:16pm

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

Community Member, 97 Posts

6 January 2010 at 1:18pm

Edited: 06/01/2010 1:19pm

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

Community Member, 224 Posts

6 January 2010 at 1:49pm

Edited: 06/01/2010 4:55pm

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
dhensby

Community Member, 253 Posts

6 January 2010 at 2:29pm

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

Community Member, 224 Posts

6 January 2010 at 2:46pm

Edited: 06/01/2010 2:47pm

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

Community Member, 145 Posts

6 January 2010 at 3:03pm

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

Community Member, 224 Posts

6 January 2010 at 3:33pm

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

Community Member, 145 Posts

6 January 2010 at 3:48pm

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