vapid icon indicating copy to clipboard operation
vapid copied to clipboard

Content Type "Alias"?!

Open iocron opened this issue 6 years ago • 5 comments

A content type to choose from a entry of Section B inside a entry of Section A would be very helpful to be more flexible. E.g. having two sections with a structure like this:

A. Pages (multiple)

  • Title
  • Choose a Gallery

B. Galleries (multiple)

  • Image(s)
  • Caption Text

With this the user could select one of the Gallery Entries on a Pages Entry. This would be very benefical to crosslink contents between different section and to organize them, as well as reuse them in a more efficient way.

iocron avatar Oct 02 '18 20:10 iocron

@iocron Thanks for submitting this.

In the original draft for Vapid, I had something similar: type=reference. In that context, I imagined categorized links, a la https://trentwalton.com/info/.

The problem I ran into was that it would require some kind of querying mechanism for sections. e.g., {{#section links where=...}}, and I was having a hard time figuring out a simple syntax. Your example is much more straightforward and easier to imagine how it might work.

Still, I think an alias/reference directive would need to support both scenarios: referencing another record and narrowing a subset of records.

I'm curious to hear other use cases you have in mind.

srobbin avatar Oct 06 '18 19:10 srobbin

@srobbin Thank you for your feedback. I had something similar in mind, but for simplicity and flexibility I was thinking about a new content type e.g. "alias" (or "reference") so the dashboard user can select one or multiple entries of a section inside another sections entry:

pages.html:

{{#section Pages}}
{{pageTitle type=text}}
{{pageGallery type=alias target=Galleries multiple=true label="Select a Gallery (or multiple)"}}
{{/section}}

galleries.html

{{#section Galleries}}
{{galleryTitle type=text}}
{{galleryCaption type=text}}
{{galleryImage type=image}}
{{/section}}

In Addition, referencing only parts of the section with the content type "alias" could be accomplished through a additional parameter (filter="...", similar to your "where" statement) if really needed, e.g.: {{pageGallery type=alias target=Galleries filter="galleryTitle|galleryImage"}}

The only problem with the "filter" solution I see are regular html tags / wrappers, those are ignored, if we have something like this: <div class="galleryImage">{{galleryImage type=image}}</div>

They would need a own section, so the wrapper (div, etc.) are included as well. Another alternative would be DOM Parent Traversal (traversing up the dom tree of the filtered element until it hits the section). Or a implementation of a dom selector, e.g.: filter=".galleryImage"

I think this solution gives the user a very modular ability to share / reference content between sections and to organize / split everything for a better overview / structure of the backend (the "filter" / where parameter would be only optional, the mentioned solution without the "filter/where" would be already great).

I see many use cases especially in Blogs / Blog Archives, Crosslinked Categories / Crossselling, creating a own section "Filemanager" for managing the images and just referencing them in other sections, custom SEO Implementations (canonical, etc.), shared Galleries, multiple views on different sections (by using filter=...), independent Navigation Trees, etc.. The possibilites are endless :)

I hope I was able to explain it well enough.

iocron avatar Oct 07 '18 16:10 iocron

This issue has been automatically marked as stale after 90 days of inactivity. It will be closed if no further activity occurs.

stale[bot] avatar Jan 05 '19 16:01 stale[bot]

Hey! This is a great idea and would make vapid incredibly powerful. I asked a similar question in the forums here: https://forums.vapid.com/t/data-linking-is-it-possible-to-associate-data-in-multiple-places-conditionally/179

I think @iocron's idea is a good one, but unfortunately it's out of my realm of expertise to try and put a PR together for this.

zohf avatar Jan 10 '19 18:01 zohf

This concept is touched upon in a new way over in #158 🙂

By pulling out pages into a top-level concept, the {{#section collectionName multiple=true}} (or {{#collection collectionName}}...) blocks essentially become just another field time to display in the dashboard where you can select the collection you want to display on that specific page. As I mention later in the proposal, you could theoretically add advanced configurations to override the template-provided defaults for limit, order, and even add a more detailed filter option.

This has the added benefit of putting power in the content creator's hands to select the articles they want to feature – something that avid bloggers, store owners, and marketers will be adamant about I'm sure!

@iocron, if #158 is implemented your above example would look something like this:

<!-- page.html -->
{{this.pageTitle type=text}}
{{#collection galleries as |gallery|}}
  <a href={{gallery._permalink}}>{{gallery.title}}</a>
{{/collection}}
<!-- collections/gallery.html -->
{{this.title type=text}}
{{this.caption type=text}}
{{this.image type=image}}

(@srobbin, forgot to mention the as |scopedName| feature in #158 – this is a new Glimmer feature to avoid scope unwrapping in newer versions of the templating language. We can offer it ony as a feature for {{#collection}} and leave {{#section}} alone with its current unwrapping behavior for back compat)

amiller-gh avatar Oct 30 '19 20:10 amiller-gh