5

I am using the Paragraphs module version 7.x-1.0-beta6 I have a bundle with the machine name: text_buttons

In the paragraphs module there are two theme suggestions:

 paragraphs-items.tpl.php
 paragraphs-item.tpl.php

if I copy paragraphs-items.tpl.php to my template folder under my theme, i can modify the code and see the changes reflect site wide wherever there is a paragraph bundle.

Now when I go to target a specific paragraph bundle nothing happens at all. I've followed the solutions in the following threads:

Nothing seems to work. Is the module currently broken? do I have to implement some sort of theme hook? I've made sure to flush caches on every change just to ensure I would be seeing the template file but it doesn't work, I've never had a problem with finding theme names before.. The documentation is non-existent for this module, and i really don't want to dig into the module code right now.

Another thing to note is that paragraphs-item.tpl.php does nothing on my website from either the module or my theme directory. it seems only paragraphs-items.tpl.php works out of the box.

I've tried:

paragraphs-items--text-buttons.tpl.php
paragraphs-items--text_buttons.tpl.php
paragraphs-items-text-buttons.tpl.php
paragraphs-items-text_buttons.tpl.php

field--paragraphs-items--text-buttons.tpl.php
field-paragraphs-items--text-buttons.tpl.php
field--paragraphs-items--text_buttons.tpl.php
field-paragraphs-items--text_buttons.tpl.php

field--paragraphs-items-text-buttons.tpl.php
field-paragraphs-items-text-buttons.tpl.php
field--paragraphs-items-text_buttons.tpl.php
field-paragraphs-items-text_buttons.tpl.php

Anyone have an idea why I can't theme my paragraph bundles?

1
  • Mind accepting my answer?
    – No Sssweat
    Feb 15, 2018 at 10:25

4 Answers 4

9

I had the same question. Here's what worked for me with: Drupal 7.41, Paragraphs 7.x-1.0-rc4.

  1. Go to the end of your settings.php file and remove the hash sign to enable "$conf['theme_debug'] = TRUE;" Or add the line if not present.
  2. Flush your cache.
  3. With your favorite browser, inspect the Paragraph output that you want to override. You should now have HTML comments, just before the actual markup, with template filename suggestions that you can use in your theme.

With my setup, the template filename suggestions are:

paragraphs-items--{field name}--{view mode}.tpl.php
paragraphs-items--{field name}.tpl.php
paragraphs-items.tpl.php

Where field name is the name of the field you use when you assign the paragraph field to a content type (not the Paragraph bundle name).

So in your particular case, if the paragraph field happened to be named "text-buttons" (machine name "field_text_buttons"), the filename suggestions are:

paragraphs-items--field-text-buttons--full.tpl.php
paragraphs-items--field-text-buttons.tpl.php
paragraphs-items.tpl.php

Don't forget to turn off theme debugging on your production site.

Best of luck.

3

You were soo close, but there is no s in item when using bundle.

paragraphs-item--[bundle-name].tpl.php

so for you:

paragraphs-item--text-buttons.tpl.php


You can add the view mode if you want:

paragraphs-item--[bundle-name]--[view-mode].tpl.php

2
  • 1
    You don't have some samples handy to illustrate (give inspiration to people like me ...) how you could actually use that "view-mode"? Just a wild guess (not such if it makes sense): for any view mode different from view mode X, only show some type of reduces/condensed version of the paragraph. Or do you think this would be woth a "real" question I should post (so that you have more room to post a specific answer)? Nov 17, 2017 at 14:49
  • 1
    @Pierre.Vriens I think you answered your own question. You can use the view mode to target a specific view (ie: teaser) and print different paragraph fields or the give div wrappers different classes.
    – No Sssweat
    Nov 17, 2017 at 23:38
2

If you have the Edgy module installed the template prefix is edgy-.

So in your case it would be edgy-paragraphs-item--text-buttons.tpl.php

Edgy:

Edgy allows site builders to display Paragraph items edge-to-edge. It does this by controlling the placement of the .container Bootstrap class.

Using a combination of Paragraphs, Panelizer and Edgy, site builders can create powerful edge-to-edge landing pages. Bootstrap is not a requirement and any theme can be used, however, just make sure you have a container class which centers content.

2

I believe that theming paragraphs-item does not work as the theming function for a paragraph_item is never actually called:

Paragraphs includes a theme template declaration for paragraphs-item, however the ParagraphItemEntity class never uses this, instead it passes the rendering to EntityAPIController, which uses #theme = 'entity'.

This is probably acceptable, but the theme declaration should be removed if that is the case.

from bug in paragraphs module: Paragraphs never calls #theme paragraph_item

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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