Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: creating a widget that displays content from another collection #1331

Closed
hamishtaplin opened this issue Apr 30, 2018 · 3 comments
Closed

Comments

@hamishtaplin
Copy link

So I'm trying to provide a UI that allows my client to select which items from a collection (work) will appear on the homepage and be able to control the order they display (preferably drag and drop).

My initial thought was to create list widget of relationship fields but this isn't the most user-friendly approach.

Is it possible to write a custom widget that pulls data (title, image, etc) from another collection? I can probably implement the drag/drop myself but would be great if there was some existing widget (ie. list) that I could wrap things in.

Here's a copy of my config.

backend:
  name: git-gateway
  branch: master # Branch to update (optional; defaults to master)
media_folder: "static/images/uploads"
public_folder: /images/uploads
collections:
  - name: "work" # Used in routes, e.g., /admin/collections/blog
    label: "Work" # Used in the UI
    folder: "src/pages/work" # The path to the folder where the documents are stored
    create: true # Allow users to create new documents in this collection
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
    fields: # The fields for each document, usually in front matter
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Subtitle", name: "subtitle", widget: "string"}
      - {label: "Vimeo ID", name: "vimeoid", widget: "string"}
      - {label: "Featured Image", name: "image", widget: "image"}
      - {label: "Body", name: "body", widget: "markdown"}
  - name: "pages"
    label: "Pages"
    files:
    - file: "src/pages/home.md"
      label: "Home"
      name: "home"
      fields:
        - {name: "philosophyTitle", label: "Philosophy title", widget: string}
        - {name: "philosophyContent", label: "Philosophy content", widget: markdown}
        - {name: "approachTitle", label: "Approach title", widget: string}
        - {name: "approachContent", label: "Approach content", widget: markdown}
        - label: "Work"
          name: "work"
          widget: "list"
          fields: 
            - {name: "workItem", label: "Work Item", widget: "relation", collection: "work", searchFields: ["title", "subtitle"], valueField: "title" }
@erquhart
Copy link
Contributor

erquhart commented May 5, 2018

I believe the new multipurpose select widget will do the trick for you once completed: #1100

Sent with GitHawk

@stale
Copy link

stale bot commented Oct 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Oct 29, 2019
@martinjagodic
Copy link
Member

Closing as stale and/or outdated.

@martinjagodic martinjagodic closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants