This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » sfConfig::get array problems
sfConfig::get array problems [message #43945] Tue, 22 January 2008 22:17 Go to next message
ifilipov  is currently offline ifilipov
Messages: 2
Registered: January 2008
Junior Member
Hey guys,
my navigation is located in app.yml
all:
  navigation:
    Home: index.php
    About us: about.php
    Events: events.php
    Mailing List: mlist.php
    Contact Us: feedback.php

i'm trying to put all this in array, but it doesn't work.
$nav = sfConfig::get('app_navigation');
print_r($nav);


help please?

[Updated on: Tue, 22 January 2008 22:19]

Re: sfConfig::get array problems [message #43948 is a reply to message #43945 ] Wed, 23 January 2008 00:59 Go to previous messageGo to next message
michael.piecko  is currently offline michael.piecko
Messages: 624
Registered: June 2006
Location: Germany
Faithful Member
Don't ask me why, but it will work this way Cool :

all:
  navigation:
    list:
      Home: index.php
      About us: about.php
      Events: events.php
      Mailing List: mlist.php
      Contact Us: feedback.php

And to access it:

$nav = sfConfig::get('app_navigation_list');
print_r($nav);

I think i remember somewhere a statement, that arrays only will work at the third level (here "list") in a yml.

Michael
Re: sfConfig::get array problems [message #43955 is a reply to message #43945 ] Wed, 23 January 2008 10:55 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
I believe to collapse things down to an array, you can also use the dotted syntax, something like this:

all:
  .settings
    navigation:
      Home: index.php
      About us: about.php
      Events: events.php
      Mailing List: mlist.php
      Contact Us: feedback.php

The dotted word can be anything, and is ignored by the YAML parser. Then to access it:

<?php
$nav 
sfConfig::get('app_navigation');
print_r($nav);
?>


(If that doesn't work, try swapping the place of ".settings" and "nagivation")


Remember Palestine
Re: sfConfig::get array problems [message #56455 is a reply to message #43955 ] Fri, 18 July 2008 11:08 Go to previous message
nikochan  is currently offline nikochan
Messages: 1
Registered: July 2008
Location: Vilafranca del Penedès
Junior Member

the solution that work for me is:

all:
  .array:
    navigation:
      Home: index.php
      About us: about.php
      Events: events.php
      Mailing List: mlist.php
      Contact Us: feedback.php


<?php
$nav = sfConfig::get('app_navigation');
print_r($nav);
?>


Marc Nicolàs i Aragó
mail: marc.niko at { gmail dot com | josoc dot com }
blog: http://pastoretdelamuntanya.blogspot.com
Previous Topic:Propel - RelatedBy
Next Topic:How to tell if configuration has been changed
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software