With the current state of the module when a config page is created and renderized and the current context doesn't exist nothing is displayed. Correct me if I am wrong.

I would like to introduce the concept of a falling back to a certain context that is configurable on the config page type for whenever a config page is not found with the current context.

Example: falling back to the default language when there is no config page for the current language.

Do you consider this a useful feature?

Comments

rodrigoaguilera created an issue. See original summary.

rodrigoaguilera’s picture

Status: Active » Needs review
StatusFileSize
new2.64 KB

Here is my approach.

In the config page type form I add a new textfield for each context so is possible to add a value.
When loading a config page I added a second query modifying the context with the fallback.

grimreaper’s picture

Status: Needs review » Reviewed & tested by the community

Hi rodrigoaguilera,

Thanks you very much for the patch!

I encountered the same problem. Here is my review. Only minor things.

  1. +++ b/src/ConfigPagesTypeForm.php
    @@ -166,6 +166,20 @@ class ConfigPagesTypeForm extends EntityForm {
    +      '#markup' => t('Fallback for contexts'),
    

    In OOP code, $this->t() should be used with the stringtranslation trait. But Maybe you have done it this way to stay in the same style as the rest of the code.

  2. +++ b/src/ConfigPagesTypeForm.php
    @@ -166,6 +166,20 @@ class ConfigPagesTypeForm extends EntityForm {
    +      $form['context']['fallback'][$contextId] = [
    

    The config_pages.schema.yml should be updated. But I don't know if this information should not be by context plugin.

  3. +++ b/src/Entity/ConfigPages.php
    @@ -193,6 +193,14 @@ class ConfigPages extends ContentEntityBase implements ConfigPagesInterface {
    +      $conditions['context'] = $type->getContextData(TRUE);;
    

    Double ;;

rodrigoaguilera’s picture

Thanks for taking the time to review :)
I'm not working in projects that use this module anymore.
Feel free to take over the patch.

hdnag’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Smile Drupal contribution tour 2019, +Smile Contribution Tour 2019
StatusFileSize
new3.75 KB

Hi,

Here's a corrected patch.

Thanks for review.

Regards.

grimreaper’s picture

Status: Needs review » Reviewed & tested by the community

Hello,

Thanks for the new patch.

It is good for me.

Waiting for maintainer reply.

  • Qwaygon committed 6626e2c on 8.x-2.x
    Issue #2985555 by hdnag: Add the concept of fallback context for a...

  • Qwaygon committed 4e6b859 on 8.x-2.x authored by hdnag
    Issue #2985555 by rodrigoaguilera, hdnag: Add the concept of fallback...
qwaygon’s picture

Status: Reviewed & tested by the community » Fixed

Included in 2.6, tnx guys

grimreaper’s picture

Hello,

Thanks to have merged this.

My 2 cents about credit attribution.

As rodrigoaguilera has made the first patch and as hdnag has only made the changed of my review, I think the commit author should have been rodrigoaguilera.

Or both rodrigoaguilera and hdnag, because if you want to give commit credits to several people, you can make empty commits.

And also with empty commits, no need to revert a commit for proper credit attribution.

Also when people tests patches and makes review (as I had done it in comment 3), you can add them in the commit message.

qwaygon’s picture

hello, @Grimreaper i just used commit message default generated by drupal org for credits, and revert trick was to keep link with the actual code lines as i dont know how can i alter commit message of commit that is already pushed to remote (without force push), anyway if you can explain it in PM would be great (so i can add you to credits without addint any new commits)

grimreaper’s picture

Hello Qwaygon,

Yes, once a commit is pushed on a release branch on Drupal.org, you can't modify it. Ok for the lines of codes I didn't thought about that or look into details on that. Thanks for the explaination.

I recently learned on an issue (https://www.drupal.org/project/menu_per_role/issues/3039205) that you can reattribute issue credits (not the commit credit) by posting a new comment. Unfortunately it does not appear on the comments.

At the bottom of the comment form, you have a "Credit & committing" fieldset where you can give proper credit attribution.

Even without committing, if you check the checkbox in front of people and then post the comment people should be creditted. And also that way you can change the default drupal.org commit message.

;)

I saw you asked for a PM message, but as there is currently no private info here, I prefer making a public comment, because as I am mentoring people during the Smile Drupal contribution tour, I can give examples on how to use the credit tools.

There is no offense here, that's absolutely not the goal. I hope you didn't took it in that way. I am only doing mentoring stuff that I think are important.

Regards and have a nice day :)

qwaygon’s picture

like this?

grimreaper’s picture

Yep,

Now I see issue credit on the profiles of rodrigoaguilera, hdnag and myself.

Thanks!

You have removed yourself the issue credit (not the credit in commit). I don't know if it was intended.

Remember each time you post a new comment, it is its credit attribution that is used. :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.