sculpin / sculpin

Sculpin — Static Site Generator
https://sculpin.io
MIT License
1.46k stars 194 forks source link

All content types still seen as 'posts' to the paginator #110

Closed PJnes closed 2 years ago

PJnes commented 10 years ago

I've just upgraded the latest version of Sculpin, and as a Drupal guy, the new content type features seem pretty interesting. One minor bug I've found is that telling the paginator to use 'posts' will list all content types, not just those from the 'posts' content type.

Worked around it by renaming my posts content type to 'articles'.

You can see an example of it in the 'broken-pagination' branch in my repo: https://bitbucket.org/pj/pauljones.io/src/34e68095b4df9983f50d03a25e43d8738fe541d6/?at=broken-pagination

PJnes commented 10 years ago

Thinking about this a little bit more, this behaviour could actually be useful if you wanted to create a listing of all posts on the site, regardless of content type.

Not sure if this just needs to be documented somewhere that posts will list all posts from all content types, rather than just the posts content type.

simensen commented 10 years ago

It is definitely a bug if you use posts and it paginates everything. I'll have to look into this more.

I'm not exactly sure how an "all" content types data provider would work. I can see a use case for that but I think that the use case for wanting each content type individually is more common?

PJnes commented 10 years ago

Oh definitely more common, agreed. Was just something I thought of when thinking about generating a sitemap.xml file.

PJnes commented 10 years ago

Aha! The bug isn't what I thought it was at all! My other content type was 'old_posts', so it was picking up the 'posts' part of the the name in the source directory. Have just tested by renaming my content type folders to 'articles' and 'old_articles' and I see the same behaviour.

Looks like there's a issue in the content type logic when it's looking at the paths. Seems to match any folder containing the path rather than a folder that matches exactly?

simensen commented 10 years ago

Do you have sculpin checked out as source? If so, you can try adding a trailing slash here:

https://github.com/sculpin/sculpin/blob/master/src/Sculpin/Bundle/ContentTypesBundle/DependencyInjection/SculpinContentTypesExtension.php#L90

Basically:

$setup['path'] = array('_'.$type.'/');

That would probably fix it. :) If so, if you want to send a PR that would be awesome.

If you don't have the source code out, I'll try to see if I can test this and fix it soonish.

PJnes commented 10 years ago

Don't have it checked out from source, but will try it out tomorrow, see if it fixes the problem.

PJnes commented 10 years ago

Tried this, and still seeing the same problem. Can also test this without having to compile from source by just adding the slash to the sculpin_content_types.articles.path value as well.

kclarkson commented 10 years ago

My problem is that only the original "blog" posts were showing. I looked at some code and in the documentation and was missing provider: data.projects. So the documentation should be updated title: Projects generator: pagination pagination: max_per_page: 5 provider: data.projects use:

alexeych commented 9 years ago

BTW, how about "all" data type? I don't use posts content type (not a blog), but use several custom content types. And to generate sitemap.xml I need to iterate all my pages (with various content types). Cannot understand how can I iterate all pages in a single loop?