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

Document "Create Custom Content Type" #121

Open
joemoe opened this issue Oct 12, 2015 · 6 comments
Open

Document "Create Custom Content Type" #121

joemoe opened this issue Oct 12, 2015 · 6 comments

Comments

@joemoe
Copy link
Contributor

joemoe commented Oct 12, 2015

sulu/sulu#451 (comment)

@joemoe joemoe changed the title Document "Create own Content Type" Document "Create Custom Content Type" Oct 12, 2015
@SalvatorePollaci
Copy link

Any updates on this?
Thank you

@danrot
Copy link
Contributor

danrot commented Dec 9, 2016

No, there are no updates until now...

@cioddi
Copy link

cioddi commented Apr 7, 2017

Can you hint us on a sample implementation of a simple custom content type.
Or which classes, template and config files are required to get it done and how to correctly register it to the sulu cms system.

If I look at SingleInternalLink (choose it to avoid naming collisions when searching through the whole project). I can find the following files:

  • vendor/sulu/sulu/src/Sulu/Bundle/ContentBundle/Content/Types/SingleInternalLink.php // Content type class that extens Sulu\Component\Content\SimpleContentType
  • vendor/sulu/sulu/src/Sulu/Bundle/ContentBundle/Resources/public/js/components/single-internal-link/main.js // A class that handles some sulu admin form field behaviours, in this case the link selection. This is (seems to be) not necessarily required for any fieldtype, but probably useful in many "custom content type" use cases.
  • vendor/sulu/sulu/src/Sulu/Bundle/ContentBundle/Resources/config/content_types.xml // This seems to be needed to register the content types

@wachterjohannes
Copy link
Member

There are 4 points you have to do.

  1. Create a tagged service (sulu.content.type) which implements the ContentTypeInterface or extend SimpleContentType.
  2. Create an aura-component which implements the UI for the ContentType (see vendor/sulu/sulu/src/Sulu/Bundle/ContentBundle/Resources/public/js/components/single-internal-link/main.js)
  3. Create a data-type (see vendor/sulu/sulu/src/Sulu/Bundle/ContentBundle/Resources/public/js/validation/types/singleInternalLink.js)
  4. Create a template (see vendor/sulu/sulu/src/Sulu/Bundle/ContentBundle/Resources/views/Template/content-types/single_internal_link.html.twig) which starts the component.

@alexander-schranz
Copy link
Member

Example implementation can be found here: sulu/ExampleNewsBundle#14

@niklasnatter
Copy link
Contributor

An example implementation for Sulu 2.0 is available in the sulu-demo repository: sulu/sulu-demo#66

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

7 participants