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

Global $var access


Go to End
Reply


16 Posts   2210 Views

Avatar
MrHyde

Community Member, 23 Posts

13 January 2009 at 5:08am

Edited: 14/01/2009 12:43am

Hi, let me explain my porblem. I#m lookinfg for answers for hours.

I want a text to show up on my site's footer, so i declared a var $text in code/HomePage.php to make this text editable in the cms. Works so far. I access the var by $text in page.ss.
But it is just shown if $Layout (in page.ss) is rendered by using HomePage.ss. How do i get global access to these kind of vars?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

13 January 2009 at 5:31am

Just put it in Page.php. That's probably easiest. Everything descends from that, right?

Avatar
MrHyde

Community Member, 23 Posts

13 January 2009 at 6:20am

Edited: 13/01/2009 6:40am

I put i page.php, but still the same problem as i described above. any more ideas?

I'm doing this in page.php:

class Page_Controller extends ContentController {

function text() {
return $this->Textfromhomepagephp;
}

Avatar
UncleCheese

Forum Moderator, 4096 Posts

13 January 2009 at 6:36am

Uhh.... what is your HomePage controller doing in Page.php?!

Avatar
MrHyde

Community Member, 23 Posts

13 January 2009 at 6:41am

Edited: 13/01/2009 6:41am

Well, just copied the wrong code from clipboard. i corrected my previous post.

Avatar
MrHyde

Community Member, 23 Posts

13 January 2009 at 11:52pm

I really need your help this. I'm currently working with this code in

page.php

class Page_Controller extends ContentController {

function text() {
return DataObject::get_one('HomePage',$var);
}
}


Any ideas?

Avatar
Carbon Crayon

Community Member, 598 Posts

14 January 2009 at 12:06am

return DataObject::get_one('HomePage',$var);

What are you trying to do with this line? The second argument has to be a filter (something like 'ID = $ID'). Where are you trying to get $var from as I cant see it in your function and your not passing it in....

Avatar
MrHyde

Community Member, 23 Posts

14 January 2009 at 12:42am

Hey aram, i agree that i dont really know what i'm doing there. Would be glad if you could once again read my first post and tell me how to access $var from HomePage.php in Page.php.

Go to Top