21301 Posts in 5735 Topics by 2603 members
| Go to End | Next > | |
| Author | Topic: | 1634 Views |
-
Global $var access

13 January 2009 at 5:08am Last edited: 14 January 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? -
Re: Global $var access

13 January 2009 at 5:31am
Just put it in Page.php. That's probably easiest. Everything descends from that, right?
-
Re: Global $var access

13 January 2009 at 6:20am Last edited: 13 January 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;
} -
Re: Global $var access

13 January 2009 at 6:36am
Uhh.... what is your HomePage controller doing in Page.php?!
-
Re: Global $var access

13 January 2009 at 6:41am Last edited: 13 January 2009 6:41am
Well, just copied the wrong code from clipboard. i corrected my previous post.
-
Re: Global $var access

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? -
Re: Global $var access

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....
-
Re: Global $var access

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.
| 1634 Views | ||
| Go to Top | Next > |

