Open newkind opened 8 years ago
An option: a select that works with typing using AJAX (rather than scrolling) then the list wouldn't need to load more than a few that are visible e.g. once three letters are typed an AJAX search is performed that returns 5 results... the same way that 'Search for plugins' is now working in the latest version of Wordpress.
My suggestion is to make the picker (the YAML field) as a button that triggers a modal window. Actually, it should be an input field so the user can type in (and remove) the article IDs manually, but next to the input field there should be a button that will trigger a modal window which will show all the articles with pagination and filter options.
This modal windows will actually be the one from the platform. I don't really know how it is in WP and Grav so I will explain how I imagine the joomla.articles
YAML field type.
Once you click on the button that I described above, the Joomla's modal window with the articles opens. Basically, the idea is absolutely the same as in creating a "Single Article" menu item or as you already did it in RokSprocket. This video explains what I mean :wink:
In wordpress an workaround is to input post ID, not too user friendly anyway.
@adi8i @newkind Guys, have a look at how I did it in Joomla - https://github.com/gantry/gantry5/pull/1591
It will be great if one of you can add this for WP so we can keep the "Content Array" particle relatively consistent across the different platforms.
Adi, entering the post ID manually should be fine for now... until a proper YAML field for each platform is added.
Hey guys,
I know that you have other priorities, but do you have any update about this - a "Select Single Article/Post/Page" YAML filed type? What are your plans about it? Do you still plan to implement it?
I use this code in a file
{% extends "forms/fields/input/selectize.html.twig" %}
{% block global_attributes %}
{% set post_type = field.post_type|default('page')|split(' ') %}
{% set post_status = field.post_status|default('publish') %}
{% set posts_per_page = field.posts_per_page|default('-1') %}
{% set orderby = field.orderby|default('title') %}
{% set order = field.order|default('asc') %}
{% set array = {
'post_type': post_type,
'post_status': post_status,
'posts_per_page': posts_per_page,
'orderby': orderby,
'order': order,
} %}
{% set posts = gantry.platform.call('Timber::get_posts', array) %}
{% set Options = field.selectize.Options %}
{% set options = [] %}
{% if posts %}
{% for id,post in posts %}
{% set id = post.id %}
{% set options = options|merge([{value: id, text: post.post_title}]) %}
{% endfor %}
{% set field = field|merge(field.selectize.Options|default({}))|merge({selectize: { Options: options }}) %}
{% endif %}
data-selectize="{{ (field.selectize is defined ? field.selectize|json_encode()|e('html_attr') : '') }}"
{# {% set field = field|merge(field.selectize.Options|default({}))|merge({selectize: { Options: options }}) %}
#}
{{ parent() }}
{% endblock %}
And then in the particle's YAML:
posts:
type: wordpress.posts
label: Posts
description: Individually select posts to display.
post_type: any
I have similar for categories, post types and taxonomies.
Nice, can you create a pull request for the change @AmibeWebsites ? Also, what if the site has 10 000 posts?
Contributions for Joomla and Grav are still needed :)
This issue is about PR #1503
This needs some more discussion and simultanious support for all platforms.
The main issue would be the picker for posts/articles on sites with large content ie. how would we choose/filter posts on sites that have 10 000 posts or more ? Select field would definitely not handle this.