Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Call a partial from within a partial
  • Apologies if this has been asked before, but I have searched for a while and either don't know the keywords or this hasn't been asked.

    I am using themes, and I have the navbar partial assigned on the base controller (much like fuel/depot does), I have content partial in the base layout that gets rendered fine, but that partial calls the navbar partial to render, and fails with "undefined variable: partials" -- I am assuming this is not possible, or I am doing it wrong.
  • HarroHarro
    Accepted Answer
    There is no interitance between partials.

    If your partials loads other partials, you have to pass the data on manually, either as parameters to View::forge(), using set()/set_safe(), or to render().

    If you want to pass on all variables, you can do that too.

    If you are still on PHP 5.3 (arghhh...) you can use $__data (sanitized data), if you are on PHP 5.4+, you can also use $this->data (unsanitized data).

    This is the perferred way, try not use use global data if you can avoid it.
  • I'll look at using layouts differently. The fuel/depot github repository, while not the latest FuelPHP, still gives a good example on how to use Themes. Thanks!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion