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

Added method getByPath to post model #363

Open
wants to merge 10 commits into
base: 3.0
Choose a base branch
from

Conversation

HenriqueSPin
Copy link

@HenriqueSPin HenriqueSPin commented Nov 15, 2017

Added the getByPath method to Post model extracted the logic from WP source. Allowing retrieve pages with nested paths (parent pages).

Example: A child page with the following permalink: parent/child.

This is useful in use cases where you need a "wildcard" path for the pages created in the backoffice.

So your last route may look like:

/**
 * Catch all that verifies for WP pages.
 */
Route::get('{any}', function ($any) {
    $page = Corcel\Model\Post::getByPath($any);
    if ($page) return view('page',$page);
    abort(404);
})->where('any', '.*');

@HenriqueSPin
Copy link
Author

@jgrossi I give up... the StyleCI is pointing things outside my auto PSR formatter.

Can you accept this PR and make any adjustment to code styling, etc you judge needed. Thank you.

@jgrossi
Copy link
Member

jgrossi commented Nov 15, 2017

Hey @HenriqueSPin thanks for the PR. Can you update the PR description to tell us more about what it's doing?

I've seen you created 3 or 4 PRs in the last 24 hours. In this case, it'd be nice to have a WIP: <PR title> as PR title then we won't merge it unless you remove WIP from the title. And you can add as many new commits you want to the same branch you are working (your 2.5 fork actually) and they will be pushed to this PR. No need to create another PR if you're refactoring the code, for example 😉

Thanks for contributing! 🎉

@jgrossi
Copy link
Member

jgrossi commented Nov 15, 2017

OK fine. Are you trying to get the page with child slug according to the URL http://example.com/parent/child? Like about-us/careers?

@HenriqueSPin
Copy link
Author

HenriqueSPin commented Nov 16, 2017

@jgrossi Yeap. Exactly this. No matter how many steps in the hierarchy (step1/step2/step3/stepN). The logic was directly copied from WP core.

Isn't a WIP. It's tested and working. Sorry for the amount of PRs... I didn't know I just had to push to my fork and the PR follows... I was trying to acomodate the code to Code Climate and StyleCI.

Thank you.

@HenriqueSPin
Copy link
Author

@jgrossi Any feedback?

@khaledelmahdi
Copy link

Any update about this?

@ralphmorris
Copy link

Hey! Any update here? Or does Corcel already support this? I can't see it in the docs though.

@jgrossi
Copy link
Member

jgrossi commented Jan 27, 2020

@HenriqueSPin I don't know why I didn't merge this before 😢 sorry! I changed to branch 3.0, can you update the PR before merging please?

@jgrossi jgrossi changed the base branch from 2.5 to 3.0 January 27, 2020 21:16
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.

None yet

4 participants