question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do you have a Generic content example?

See original GitHub issue

Hey Håkan - have just started using Piranha and loving it!

I’m trying out rc2 and am eager to see the generic content content stuff. I can see in the source that there’s a manager page for groups etc, was wondering if you had a quick example somewhere on how to preview it…?

I managed to get as far as this, but I was not able to create a new “Product” from the management screen - keeps flagging a console error "Cannot read property ‘create’ of undefined… I’m guessing I have probably missed something

[ContentGroup(Title = "Content", Id = "Content")] [ContentType(Group = "Content", Id ="Product",Title = "Title")] public class ProductContent : Content<ProductContent> { [Region(Title = "Zoom")] public TextField SomeText{ get; set; } }

Cheers and great job!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tidyuicommented, Feb 17, 2021

Hi there! We’re working on the new documentation sections for 9.0, so it’s not strange that you haven’t found information about it. There’s some examples on it in our repo in the RazorWeb example:

https://github.com/PiranhaCMS/piranha.core/tree/master/examples/RazorWeb/Models/Content

In short the key concept is that a Group equals an abstract base class, for example:

[ContentGroup(Title = "Products", Icon = "fas fa-hammer")]
public abstract class Product<T> : Content<T>
    where T : Product<T>
{
}

The content types available for this group is then the classes that inherit from this base class, for example:

[ContentType(Title = "Standard Product")]
public class StandardProduct : Product<StandardProduct>
{
    [Region(Title = "All fields")]
    public Regions.AllFields AllFields { get; set; }
}

Best regards

0reactions
tidyuicommented, Aug 25, 2021

The purpose is to be able to create different repositories with reusable content pieces that can be used from pages and posts.

For example groups could be Products and Banners, and in Products you could have two Content Types Computers and Monitors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is Generic Content Writing? And Why Is It Bad?
Generic content is unspecific content. It uses a blanket approach rather than drilling down to say what it means or wants to sell....
Read more >
Generic Content
Generic content mostly refers to content that is either so generic that partners don't want to accept more (ex. purely white noise) or ......
Read more >
Fight Generic Content: How to Create Interesting Posts
Spotting a generic article is easy. All you need to do is see if you can swap your main keyword for something else....
Read more >
7 ways to write about generic topics, but sound totally ...
This guest post by Victoria Greene shares some ways to make those generic topics sound a lot more interesting.
Read more >
How To Not Be a Generic Content Writer | by Manisha
A generic writer focuses more on collecting information but implements a small fraction of the advice they have learned. Unless the generic ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found