Jump to content

API how to output notes in templates (Quick guide)


Recommended Posts

Today I had to output notes in a form at the frontend.

This little code snippets show you how it can be done via the API:

1) One language site:

$notesofmyfield = $page->fields->get("myfield")->notes;
echo $notesofmyfield;

2) On a multilanguage site

if ($user->language->name != 'default') {
    $notes       = "notes{$user->language}";
} else {
    $notes       = 'notes';
$notesofmyfield = $page->fields->get("myfield")->$notes;
echo $notesofmyfield;

Happy coding!!

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By louisstephens
      I wasn't quite sure where to put this as this not really a firm question but more of a discussion (if this needs to be moved, I do apologize). I am remaking an internal app for work and most of the users log into the admin to create pages etc etc. With the old app, I have noticed a lot of unpublished pages, duplicated pages, abuse of the system (my fault as I didn't do anything to set guidelines of maintenance etc etc) and was wondering how some of you "post" notes for the  user.
      I was going to send out an automated email once I create their user account with all of useful documentation, but I feel that they will either read it once and delete it or just skip right over it. In my mind it would be nice to have a place where this information was always available, but I have a feeling that it would just be ignored after a while. Unfortunately, I dont have the time to watch the backend like a hawk for any wrong doings, but lately the old app has become the unlawful wild wild west (the page tree is getting out of hand).
  • Create New...