I’m putting together a project that requires a content type that has a numbered “How To” list in Drupal 7.5.x.
I am using the Paragraphs module and so far the basic concept of having paragraph blocks of how to “steps” is working as expected. Users are able to “Add another Paragraph” to add each additional step and the steps render correctly on the front-end display as expected.
But while that’s all fine, I’m having a heck of a time understanding how I can have Drupal/Paragraphs automatically number each paragraph so it would look like—for all intents and purposes—something like this; literally I just need that number to the left of each Step …: item and that’s it:
- Step One: Do this.
- Step Two: Do that.
- Step Three: Do something else.
I have been playing around with the Custom Formatters module and it almost seems like that might be my solution: I could use a custom formatter that uses PHP to do something like this. Let’s assume this is what outputs the title for each paragraph field_title
value with a PHP custom formatter:
return $variables['#object']->field_title['und']['0']['value'];
So I should be able to do something like this to get a number/order prepended:
return $count . ': ' . $variables['#object']->field_title['und']['0']['value'];
Of course $count
is just some arbitrary pseudo-code I am placing for example’s sake, but is this the right approach? Or am I barking up the wrong tree. FWIW, I am poking around the values of the output via the Devel module and don’t see anything useful that would related to count/order.