Add Page by Form and SimpleMDE questions

Im very happy to report these two plugins work very well together! Tx to @bleutzinn for incredibly useful work here :slight_smile: Im using both without any functional issues but Id like ideas on a couple of things. I know @pmoreno uses the add-page-by-form plugin so am tagging them in case.

Context: A logged in user creates a new note. All notes have front matter page config that allows SImpleMDE to make the content field editable. The plugin examples dont include metadata fields as editable. Form fields for each note (atm) are title, date (with picker), tags, and content. This is based on the simple example in the add-page-by-form plugin readme.

  1. Id like to display the username’s full name rather that their username. Eg not display ‘starchild’ - their username, but display ‘stan’ - their full name. I dont know how to capture this in the add-page-by-form form fields. The username is captured by include_username: true in the page config, but trying include_fullname doesnt work (nothing is visible using page.header.fullname in the twig).
  2. Id like to add or edit tags via the SimpleMDE plugin content field. Is this even possible, any ideas how I could do it? Currently tags are in the metadata, which is not editable. The content field is where SimpleMDE textarea kicks in.
  3. Id like more control of the creation date time - its defaulting to 12.00, but would be much more useful if the actual time was shown. The date is captured as shown below, so time is generated by the system, not the form field.
            name: date
            label: enter date
            validate.min: "2014-01-01"
            validate.max: "2018-12-31"
            type: date

Ideally Id like to display modified date and time too (as separate info), but thats for later.

Hope its ok to post a few questions just in case it sparks an idea in someone’s more knowledgeable brain than mine :smiley:

Updates, in case useful to others.

Create date: I checked out the add-page-by-form plugin and it is not configured at all to provide a create date. So, I added a timestamp process to the form at the bottom, to generate a timestamp to each new note, and removed the date field in the form. I then display the timestamp as the create date.

form addition:

    process:
        - 
            timestamp:
               name: timestamp

displaying the timestamp in the template simply needs {{ page.header.timestamp }}.


To display a fullname, its difficult as the add-page-by-form makes no provision for including a fullname of the user who generated the page. I edited the blueprint to test etc but to no avail. Currently Ive added the fullname as part of the new page front matter in the add page form. Its not ideal but its better than displaying the username. I cant yet think of how to make this dynamic.

Still working on how to make tags editable or to add new ones from the front end.

Hey, about displaying the fullname of users. I don’t know exactly how your users are stored, but if they are stored somewhere let’s say in a yaml file that looks like this:

someuser.yml

username: someuser
fullname: My Long Full Name
...

It’s probably not so complicated to retrieve that file and get the fullname field in it.


In a theme I created I used the following technique to store any info I wanted on users and also display a public profile page for these users:
I created a folder called authors with the following structure

/authors/
├── someuser
│   └── author.md
└── otheruser
    ├── author.md
    └── profile_image.jpg

So now (given I have an author page template) I have a page for each author accessible at /authors/<username>.

The content of the author.md file looks like this:

---
title: My Long Full Name
website: https://some.website.tld
---

Any content for this user's page.

Now if in your pages you have the username stored in header, you can retrieve infos from the user with:

{% set author_page = page.find("/authors/" ~ page.header.username) %}

User full name: {{ author_page.title }}
<a href="{{ author_page.website }}">User website</a>

{% set profile_image = author_page.media["profile_image.jpg"] %}
{% if profile_image %}
User profile image:
  <img class="author_profile_image" src="{{ profile_image.url }}" alt="{{ page.header.username }}" />
{% endif %}

...

Like this you have one source of info on your users which is their profile page. And you can use it easily to populate elements in any other page.

Hope that helps.

1 Like

@squeak thanks for the time you took to provide this info. This might do it. Thank you.

The app will only be used by a specific person or small group of people because it is a personal information app, not intended for public use. But having a way of generating the fullname for a note made if several people share the app for a specific reason or project would be very useful. Generating the fullname on the fly when a new page is created is difficult, but matching it to existing user accounts in the way you describe could be the solution.