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

Fix custom Entry slug on embedded Views (#2207) #2222

Conversation

doekenorg
Copy link
Contributor

@doekenorg doekenorg commented Nov 27, 2024

This PR addresses #2207

When using shortcodes, its hard to determine the correct View for its settings. This PR records the View when the shortcode is being rendered. Based on that value we can now determine the settings correctly. After the shortcode is rendered it forgets the View.

For testing, also test multiple Views on the same page with different Entry slug settings.

💾 Build file (6dcf3f8).

@doekenorg
Copy link
Contributor Author

@Mwalek Please test this one. All the permalink structures should still work.

@Mwalek
Copy link

Mwalek commented Nov 27, 2024

@doekenorg I observed the following issues while testing:

  1. Missing "Go Back" Link: The "Go Back" link occasionally does not appear when viewing a single entry. This can be reproduced by opening different single entries in new tabs multiple times.
  2. Custom Page Headings on Single Entry Screens: Custom page headings are incorrectly displayed on single entry screens, which deviates from the expected behavior.
Screenshot 2024-11-27 at 3 52 20 PM Screenshot 2024-11-27 at 3 51 46 PM
  1. PHP 8.3 Deprecation Warning: Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /.../wp-content/plugins/gravityview/future/includes/class-gv-permalinks.php on line 282
Screenshot 2024-11-27 at 3 33 13 PM
  1. Multiple Entries Displayed on Single Entry Screen: Occasionally, multiple entries are displayed when opening a single entry.

Steps to Reproduce

  1. Create two Views, each with a different single entry slug URL.
  2. Create a new page.
  3. Add two Heading blocks to the page, each with custom text corresponding to one of the Views.
  4. Copy the shortcodes for the Views and embed them in the page using Shortcode blocks.
  5. Publish the page and view it on the front end.
  6. Click on different single entries and observe the results.

Issue Summary

  • "Go Back" link missing when opening single entries in new tabs.
  • Custom headings shown on single entry screens.
  • PHP 8.3: Deprecated trim() warning.
  • Multiple entries displayed on single entry screens.

@Mwalek Mwalek assigned doekenorg and unassigned Mwalek Nov 27, 2024
@mrcasual mrcasual requested a review from Mwalek November 27, 2024 15:14
@doekenorg
Copy link
Contributor Author

doekenorg commented Nov 27, 2024

@doekenorg I observed the following issues while testing:

  1. Missing "Go Back" Link: The "Go Back" link occasionally does not appear when viewing a single entry. This can be reproduced by opening different single entries in new tabs multiple times.
  2. Custom Page Headings on Single Entry Screens: Custom page headings are incorrectly displayed on single entry screens, which deviates from the expected behavior.

Screenshot 2024-11-27 at 3 52 20 PM Screenshot 2024-11-27 at 3 51 46 PM
3. PHP 8.3 Deprecation Warning: Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /.../wp-content/plugins/gravityview/future/includes/class-gv-permalinks.php on line 282

Screenshot 2024-11-27 at 3 33 13 PM 4. **Multiple Entries Displayed on Single Entry Screen:** Occasionally, multiple entries are displayed when opening a single entry.

Steps to Reproduce

  1. Create two Views, each with a different single entry slug URL.
  2. Create a new page.
  3. Add two Heading blocks to the page, each with custom text corresponding to one of the Views.
  4. Copy the shortcodes for the Views and embed them in the page using Shortcode blocks.
  5. Publish the page and view it on the front end.
  6. Click on different single entries and observe the results.

Issue Summary

  • "Go Back" link missing when opening single entries in new tabs.
  • Custom headings shown on single entry screens.
  • PHP 8.3: Deprecated trim() warning.
  • Multiple entries displayed on single entry screens.

@Mwalek

  1. I cannot reproduce this at all.
  2. Blocks are not connected to the shortcode. If you see a single entry, it should only THAT GravityView shortcode. So it may look weird; But I'm not sure it's wrong. Let's look at it tomorrow together. Or can you create a loom for what you mean, if I don't understand correctly.
  3. This should be fixed now
  4. Can't reproduce this either. Can you create a loom where this happens?

@Mwalek
Copy link

Mwalek commented Nov 28, 2024

@doekenorg, that's strange. I tried in a clean browser and could still replicate the behavior. Could you please try checking the behavior on the URL below and let me know the result?

https://gravityview-pr-2222.try.gravitykit.com/show-views/

@doekenorg
Copy link
Contributor Author

Ok, so 1 issue remains; and I'm not sure thats gonna be an easy fix; or if we need to address this immediately.

The problem here is that there are multiple views connected to the same form and entries. Every entry get's a single unique ID stored on the entry. If multiple views connect to the same entry; and have different entry slugs, they will keep fighting over the precedence. And a slow DB will cause a timing issue.

This problem is not new to this solution; this problem is already part of GravityView; but it showed itself here because of this particular set up.

The only solution is to have a new View specific meta key per entry that contains the entry slug for that view, so we can lookup the correct entry based on the combination of the View ID and the slug. This could be a nice addition; but I'm a proponent of adding this as a new feature; and ignore the issue on this PR.

@mrcasual do you have any thoughts and or objections to that?

@rafaehlers
Copy link
Contributor

@doekenorg, is there a slight chance this other issue in the Social Sharing & SEO extension is related to this limitation you've just found out?

@doekenorg
Copy link
Contributor Author

@rafaehlers No, I don't think they are related.

@mrcasual
Copy link
Collaborator

@mrcasual do you have any thoughts and or objections to that?

@doekenorg, sounds reasonable.

@Mwalek
Copy link

Mwalek commented Dec 2, 2024

@doekenorg I confirmed that only the issue planned for a future PR persists. No other issue was identified while testing this PR.

@mrcasual
Copy link
Collaborator

mrcasual commented Dec 2, 2024

@doekenorg, please create a new issue and feel free to merge this PR.

@doekenorg
Copy link
Contributor Author

New issue is #2228

@doekenorg doekenorg merged commit 9ed2157 into develop Dec 2, 2024
1 check passed
@doekenorg doekenorg deleted the issue/2207-custom-entry-slug-doesnt-work-when-view-is-embedded branch December 2, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants