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

Omitting singular_name in Contenttypes breaks URL generation during Record creation #823

Closed
GwendolenLynch opened this issue Jan 10, 2014 · 14 comments

Comments

@GwendolenLynch
Copy link
Contributor

Some words (I can only speak for how they are used in English), have the same plural as singular. e.g. "multimedia", "news", "sheep" & "moose".

Creating a content such as:

multimedia:
    name: Multimedia
    singular_name: Multimedia

Will give the error:

The name and singular_name for 'multimedia' are the same (Multimedia). Please edit contenttypes.yml, and make them distinct.

Whereas, if the singular_name variable is omitted, a blank URL stub is generated when a new Record is created with that Contenttype.

@bobdenotter
Copy link
Member

I've bumped into this once or twice as well. Although, mostly with "news" or "media".. I've never tried to create a contenttype for "sheep". ;-)

I'm not sure yet how we should fix this. The reason that Bolt complains about it, is to prevent the routes from getting confused:

http://example.org/pages - an overview listing of pages
http://example.org/page/foo - a specific page, identified by 'foo'

If we allow the singular and plural version to be the same, these routes would get messed up. To be specific:

screen shot 2014-01-10 at 17 22 28

Suggestions how we should fix this?

@GwendolenLynch
Copy link
Contributor Author

I've never tried to create a contenttype for "sheep". ;-)

All manner of laughter and further jokes went through my head reading this late on a Friday afternoon!

I'm only a day into reading Bolt documentation and code, so an immediate suggestion is beyond me. Especially considering that the above is also already mentioned in the "Templates and routing" document page (it's Friday) ;-)

Having said that and further thinking out aloud, contentlink and contentlisting theoretically should still somehow route separately as they may be similar, but not identical. But I was a victim of reading the WordPress codebase, so I am still recovering.

However, others might have better insight.

@rarila
Copy link
Contributor

rarila commented Jan 10, 2014

I also had this problem (with german words). I "solved" it by using the english words for the contentypes and some german routing that translated to the correspondending datatype. In another case I used "news" and "newsitem".

But I don't know why this could confuse the routes anyway. Without knowing anything about the internals of routing some simple regex would solve the problem:

http://example.org/sheep -> "/sheep$%" an overview listing of sheep
http://example.org/sheep/shaun -> "/sheep/(?<slug>.+)$%" - a specific page, identified by 'sheep'

Simply said, if the URL ends with the contenttype then listing is selected and if the contenttype is followed by an "selector" the selected item is displayed. Am I overseeing here something?

@CoolGoose
Copy link
Contributor

Why don't we think it "rest" like
so it's /pages for all of the item and /pages/ means we want a specifc item.
Adding query strings /pages?page=1 will keep it on /pages with the whole listing,

PS:
I'm an idiot, i was meaning exactly what @rarila said

@bobdenotter
Copy link
Member

I've looked into this a bit more.. If we decide that we will allow 'slug' and 'singular_slug' to be the same, we need to fix the routing. Not just for the frontend, but also for the backend. So, it's slightly more work than just fixing routing.yml, but it should be do-able.

@WilliamVercken
Copy link

I've bumped into this once or twice as well. Although, mostly with "news" or "media".. I've never tried to create a contenttype for "sheep". ;-)

@bobdenotter : how did you manage to solve this problem ?
I want to name my "News Item" -> News, because I want the path to be : foo.com/news/title-news-slug (for the SEO, "newsitem" is not very clean...)
But when I go to foo.com/news, I have an error page.

And there is another problem : we don't have any hand on the "plural_name". (or maybe yes and I didn't see it yet ! :) ). And for some words in french :
In english : animal -> animals.
In french : animal -> animaux (journal -> journaux, cheval (horse) -> chevaux...)

Is there a way to fix theses two problems ?

@bobdenotter
Copy link
Member

Well, turns out this was relatively easy to fix. With the above changes, you can now have a slug and singular_slug that are the same. Like 'news'. Or 'sheep'. :-)

Links like example.org/news and example.org/news/foo both work with the expected results. So, I'm closing this issue.

@WilliamVercken I think your other problem is more related to multi-lingual content than the actual contenttypes, right? You can define the slug seperate from the name, maybe that helps:

cafes:
  slug: cafes
  name: Cafés
  singular_slug: cafe
  singular_name: Café

@WilliamVercken
Copy link

Oh, I didn't know that there was that option !
So, it means that I can have :

/article/slug-article-1 => article-1
/article/ (still singular) => list of articles

?

@bobdenotter
Copy link
Member

Yes, you can do that now (after the changes i committed earlier this afternoon. ;-) )

@WilliamVercken
Copy link

Great news/sheep !
These two issues were crucial for my project... I had to considering others cms (drupal 8 alpha... I really want to use twig :) ), but now that you solved this I can return back to Bolt !

@GwendolenLynch
Copy link
Contributor Author

Excellent, thank you yet again @bobdenotter

@rarila
Copy link
Contributor

rarila commented Feb 7, 2014

Great!
I think we should dump the kitchensink example in favour of a sheep example and perhaps create a sheep named Bolty as mascot! ;-))

@GwendolenLynch
Copy link
Contributor Author

I can not tell you how much I truly love this idea, @rarila!

@mikerockett
Copy link

I, too, am very happy that this is now the case. I can finally restructure my URL tree. Thanks, @bobdenotter!

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

No branches or pull requests

6 participants