1

instead of using views, on some occasions, I want to write custom code to display a list of content. I know how to create ctools content type plugins, and in here I could create my EntityFieldQuery to display my content and allow it to be embedded. I was wondering if there are any other options for making my custom code available for embedding in a panel other than creating a ctools content type plugin as mentioned. Ctools content type plugin feel a little verbose for for the task...

1

I definitely understand your problem with a ctools pane feeling verbose.

Unfortunately I don't have a great fix. I tend to copy an old content type to a new one and edit names and such.

What you make not know is that the normal single => TRUE property of a content type can be switched to FALSE allowing the code to create multiple panes in a single content type. (Actually I think FALSE is the default, so you don't even need to).

This allows you to share a lot more code between several panes that act similarly.

Another, simpler but more limited option is Fieldable panels panes, which basically allows you to take an entity, put fields on it, and stick it directly into a variant. If your needs are simply to display simple content, that could be enough, but this isn't enough when more complex logic is needed.

Actually a pane that requires a EntityFieldQuery context as an argument and then basically just themes it would be very interesting. There's probably use for at least a sandbox that provided the context and content type for that. :)

I'll try to write up more details if necessary, but look at plugins/content_types/custom/custom.inc for an example of a content type that does the above.

Someone may also have taken the time to write a drush command to generate a content type from a template. Haven't looked around for one though.

  • This all sounds very interesting. Any further details would be welcomed. – Andrew Welch Jul 15 '13 at 14:05
  • I added a short comment with another option, but haven't really expanded the existing information. I don't currently have the time to write a really good answer, so if you can specify what you need help with, that'd make it more likely I can improve the answer. :) – Letharion Jul 15 '13 at 14:22
0

Use blocks. You can start from here.

  • Being a big Ctools fan, I strongly disagree. When someone has taken the time to improve their code quality with panes instead of blocks, (providing some level of inversion of control), please don't suggest to them that they should go back to blocks. Blocks are essentially becomes ctools panes in D8 for a reason. – Letharion Jul 8 '13 at 16:14
  • I know but it was the easiest way to go. Thanks your comment enlightens more on this. – heshanlk Jul 8 '13 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.