17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1379 Views |
-
Three links pointing to the same page - Need Title to change.

26 October 2007 at 7:02am Last edited: 26 October 2007 7:22am
Hi Guys,
I'm sure this is very easy, but I just can't put my head around it.
I have three static links that I wish to point to the same page. The only thing that needs to change is the title in the header section.
Normally I would add the variable in question to the link, like www.company,com/page/?Title='sometitle' , perform a $_GET and be done with it. I just haven't figured out how to do it within the Silverstripe scheme (which I like by the way).
Many thanks,
Todd
-
Re: Three links pointing to the same page - Need Title to change.

26 October 2007 at 9:31am
One idea is to make child methods so that its
www.mysite.com/contactus/rahrah
then you add a method called rahrah (which subclasses page?) that updates Title appropriately.
Look through the tutorial at how methods and subclassing work.The problem with /contactus/?pagetitle=RahRah is that its a bit ugly, and people can exploit it with things like ?pagetitle="I hate your mum" or "This site sucks" etc.
-
Re: Three links pointing to the same page - Need Title to change.

27 October 2007 at 1:53am Last edited: 27 October 2007 1:54am
I think you can do Sig's method like this:
so, mysite.com/about-us/cooltitle provides a custom $Title field. You can add more items to the array to make more fields, if you require it.
class Page extends SiteTree {
...
}class Page_Controller extends ContentController {
function cooltitle() {
return array(
'Title' => 'yay'
);
}}
Hope this helps!
Sean
-
Re: Three links pointing to the same page - Need Title to change.

30 October 2007 at 9:37am
Hi Sigurd, Sean,
Many thanks. Maybe I'm an idiot, but I'm still not getting it. Do I create a cooltitle.php file and put the above information into it, then call the method as a control in the contact.ss file, or do I need to create a cooltitle.ss file and call it from there, or neither?
Thanks,
Todd
-
Re: Three links pointing to the same page - Need Title to change.

30 October 2007 at 3:18pm
Hi there,
You create cooltitle() in your Page.php file, then call it as contact-us/cooltitle
So, you can then go <a href="{$Link}cooltitle">Cool stuff</a> in the template (Page.ss).
contact-us is just a standard page. If contact-us uses a page type other than Page.php then you can put it on that one, otherwise just put it on Page.php.
Note that you can call cooltitle() on any page if you put it in Page.php, because everything inherits that.
Hope this helps!
Sean
-
Re: Three links pointing to the same page - Need Title to change.

30 October 2007 at 4:35pm
Hi Sean,
Thanks a lot. Both for the code and the explanation. It worked perfectly.
Todd
| 1379 Views | ||
|
Page:
1
|
Go to Top |



