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

Provide Create content links #28

Open
olafgrabienski opened this issue Nov 25, 2020 · 10 comments
Open

Provide Create content links #28

olafgrabienski opened this issue Nov 25, 2020 · 10 comments
Labels
enhancement New feature or request

Comments

@olafgrabienski
Copy link
Member

As shown in http://modulesunraveled.com/organic-groups-7x-2x/organic-groups-layout and the following chapter, there is an option to provide Create content links like node/add/post?og_group_ref=GROUP-ID on group nodes, so that content is automatically posted to the group where you click the Create content link.

The Create content links must be configured in Organic Groups but they are provided by the Entityreference Prepopulate module which so far isn't available for Backdrop. Should we port Entityreference Prepopulate, or are there better ways to provide these links, e.g. using https://github.com/backdrop-contrib/prepopulate, or as enhancement of the OG module itself?

In my opinion, this type of Create content links is quite useful, if not practically necessary, in most use-cases.

@olafgrabienski olafgrabienski added the question Further information is requested label Nov 25, 2020
@laryn laryn added this to To do in Completing the port Mar 1, 2022
@schoenid
Copy link

schoenid commented Mar 24, 2022

@olafgrabienski I've created an example in the Prepopulate modules wiki https://github.com/backdrop-contrib/prepopulate/wiki

But there's more:
With the help of Prepopulate I was able to build a Create child book link, which replaces the standard link of the books module view. The only problem I had, was the mlid entry for books, which is not supported by views. So I had to patch the core books module as follows:

file: book.views.inc

section:

// menu_links table ...
...
$data['book_menu_links']['mlid'] = array(
    'title' => t('mlid'),
    'help' => t('The mlid of the book page.'),
    'field' => array(
        'handler' => 'views_handler_field_numeric',
        'click sortable' => TRUE,
    ),
        'sort' => array(
            'handler' => 'views_handler_sort',
    ),
);

So I used a view:

CONTEXTUAL FILTERS

Content: Nid

FIELDS

OG membership: Group ID (Group ID) [hidden]
Book: mlid (mlid) [hidden]

which let me use the following Prepopulate expression further in an additional field:

/node/add/book?edit[og_group_ref][und][0][default]=[!gid]&parent=[!mlid]

This sets the groups association and the parents mlid to a book child content.

@argiepiano
Copy link
Collaborator

argiepiano commented May 25, 2022

@olafgrabienski I agree this would be a very useful feature to have "out of the box" (thanks @schoenid for providing alternative ways). In the videos you included, this feature is provided (through a Panels' "content type") by entityreference_prepopulate. I removed this feature when I ported entityreference_prepopulate since Backdrop doesn't have Panels, but I will start an issue there and will start an adaptation of this feature so that it's available as a block through Layouts.

When that's ready I'll close this issue.

@argiepiano
Copy link
Collaborator

Issue created in entityreference_prepopulate
backdrop-contrib/entityreference_prepopulate#3

@argiepiano argiepiano added enhancement New feature or request and removed question Further information is requested labels May 25, 2022
@schoenid
Copy link

schoenid commented May 26, 2022

So I had to patch the core books module

I have allready created a PR a few weeks ago for the books mlid in file: book.views.inc ...
backdrop/backdrop#4064

@argiepiano
Copy link
Collaborator

@olafgrabienski, I just added the "Create content links" to Backdrop OG as a block (it was a Panels component in D7). Please see #119 (the latest commit there). Can you please test?

Now it's possible to add this "Create content links" block to a normal Backdrop layout. The block creates a direct link to the add form to add content to the group node being viewed.

Important: in order for this to work properly Entity Reference Prepopulate must be enabled. Otherwise the group will not be pre-selected in the group reference field in the form. See this video tutorial.

@olafgrabienski
Copy link
Member Author

Thank you very much, @argiepiano ! After applying the changes to my test site, I was able to add the block "Content create links", and the the provided links work as expected.

Actually, I wasn't sure if I a particular layout for groups is required. I had already enabled Entityreference Prepopulate and configured the field. So, after not finding the block in the "Add block" dialog of the Default layout, I added a layout with node context and the new visibility condition "Node is an OG group". Then I was able to add the block.

@argiepiano
Copy link
Collaborator

So, after not finding the block in the "Add block" dialog of the Default layout, I added a layout with node context and the new visibility condition "Node is an OG group". Then I was able to add the block.

That shouldn't be necessary. I think you did not see the block because of the location of og_block_info (it's in an inc file). I'll move it to the main module. This should solve the problem.

@argiepiano
Copy link
Collaborator

I've moved the hook_block_info implementation to the main module. This should solve the block not being visible. Closing this now as this functionality has been merged.

Completing the port automation moved this from Critical to Done May 27, 2022
@olafgrabienski
Copy link
Member Author

I've moved the hook_block_info implementation to the main module. This should solve the block not being visible.

@argiepiano I've tested this (using the OG Beta release), and the block is still not visible in the "Add block" dialog of the Default layout. One idea: in og.og.inc, should the removed part if (module_exists('entityreference_prepopulate') (line 31 ff.) be inserted in another file?

@argiepiano
Copy link
Collaborator

Reopening so that we can take a look at this again. Thanks @olafgrabienski

@argiepiano argiepiano reopened this May 30, 2022
Completing the port automation moved this from Done to In progress May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants