HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Any way to use $Configuration variables in locale.php $Definition assignments?

[Vanilla 3.3]

TL;DR: If I have $Configuration['Garden']['Foo'] = 'Bar' in my config.php, and I want to set $Definition['Something'] = 'Something Something Bar Something'in my locale.php, is there a way to make Bar come from the $Configuration setting rather than hardcoding it?

In detail:

I'm trying to change my registration form to link to my Privacy Policy as well as my Terms of Service. Thanks to other forum posts I've found here, I'm doing that by setting a $Definition in my conf/locale.php rather than editing stuff in applications/dashboard/views/ directly.

Ideally, I'd like to set this up with a configuration variable analogous to  $Configuration['Garden']['TermsOfService'] so I can keep my registration URLs in a single place - say,  $Configuration['Garden']['PrivacyPolicy'].

But I haven't been able to figure out how I'd access such a variable in my $Definition assignment.

  • The TOS configuration variable is included via %s; I can't use that without changing the view directly.
  • This comment and the one below it imply I should be able to use something like , but I haven't been able to get that to work, and searching hasn't gotten me anywhere.

Any advice?

Comments

  • R_JR_J Ex-Fanboy Munich Admin
    edited July 2020

    One terribly ugly way would be to use php code in the locale file:

    if !isset $Configuration include config.php

    $tos = "bla bla bla {$Configuration['What']['Ever']}";

    unset $Configuration


    The cleaner approach would be a "Update TOS" plugin:

    The plugin provides simple text area for the TOS

    That text will be saved to the UserMeta table

    It will be processed with sprintf and the urls

    The resulting TOS will be saved to the locale file


    ALthough such a plugin would be very easy to write, I doubt it's worth the effort. Why don't you do that manually? Do you change those urls often?

  • Thanks for the reply!

    I've done it manually, but wanted to make sure I wasn't missing an entire system of how things worked / ought to be done in Vanilla - the comment I failed to link to (https://open.vanillaforums.com/discussion/comment/207112/#Comment_207112) seemed to imply that there was a simple and correct way to do it, but I neither understood that way nor could I get it to work with some simple experimentation.

    (I'm still in the learning stage where I don't know what I don't know, if that makes sense?)

  • R_JR_J Ex-Fanboy Munich Admin

    Just practice asking. You'll quickly learn what to for ;-)

Sign In or Register to comment.