Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Elegant way of using language class with a HTML tag
  • I have a line in a language config...

    'learn_more' => 'To get started, learn more',

    But I only want the ‘learn more’ bit to be a link.

    Example desire output:

    To get started, <a href="#">learn more</a>

    I’m looking for the most elegant way of doing this, without splitting it into two strings.

    Something similar to the way printf() works:

    'learn_more' => 'To get started, learn more about %s',
    printf(__('product.learn_more'), $product_name);
  • HarroHarro
    Accepted Answer
    Lang supports named parameters on both the Lang::get() method and the __() helper.

    'learn_more' => 'To get started, learn more about :product',

    And use:

    echo __('product.learn_more'), array('product' => $product_name));
  • Thanks Harrow!

    Can you think of an elegant way to combine that with Html::anchor() to just have the ‘learn more’ in an anchor tag, but without separating it into two values?
  • No, not directly, other than to put the HTML in the language string (which imho is not really a solution).

  • Yeah that’s what I was trying to avoid, thanks anyway!

Howdy, Stranger!

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

In this Discussion