View Source Elph.Contents.ContentType behaviour (elph v0.9.1)

This module provides macros to help with creation of custom content types.

Start with a schema freshly created by mix phx.gen.schema Contents.Types.Markdown markdown_contents markdown:text

Now change some stuff in the <YourApp>.Contents.Types.Markdown module.

  • Add use Ecto.Contents.ContentType below use Ecto.Schema.
  • Change schema "markdown_contents" do to content_schema "markdown_contents" do.
  • Remove the timestamps() call in your schema as Elph already manages timestamps.
  • Write your changeset as you would usually and only care about your own stuff. Don't embed or cast the content. This is already handled.
    • Care! The function has to be called changeset so it can be called by Elph

Link to this section Summary

Link to this section Callbacks

Link to this callback

after_delete_callback(term)

View Source
@callback after_delete_callback(term()) :: term()
@callback changeset(term(), term()) :: term()
@callback content_preloads(term()) :: term()
@callback preloads(term()) :: term()

Link to this section Functions

Link to this macro

content_schema(name, list)

View Source (macro)