Unique field idx and getProperty->linear cb

Hi,

I would like to get a specific cb field in a snippet. The cbGetFieldContent is not an option here, because I do not know how many times the field exists on the page. To get the cb content, I am using
$cbarray = $resource->getProperty('linear', 'contentblocks');

As snippet input property I use unique idx and thought I could use it as an array index for the $cbarray. However, it seems, that the unique idx increments with each new layout. Is there a way to get the correct array position of the field in a placeholder, so I could pass it to my snippet?

Thanks!

I found a solution for this. In components/contentblocks/model/contentblocks/contentblocks.class.php I added the public var $uniqueFieldIdx and placeholder unique_field_idx which increments with each field like unique_idx does, but not with layouts or colums.

Is it possible to integrate this in one of the next content blocks updates?

Hey @devumapp - can you elaborate on what you’re hoping to achieve? There’s already a field_idx getting set.

Hey @mhamstra,

I was looking for (and successfully found) a workaround for this issue: Uncached Snippet Calls in Fields not working correctly with properties - I call a chunk without any properties in the cb template and in this chunk, I am calling an uncached snippet, in which I retrieve all the settings and content of the cb field i wanted to display.

Regarding field idx: I just tested it again and the output of [[+field_idx]] in a field template is empty (using the current cb version). I had a look at contentblocks.class.php and there is no indication that a field_idx placeholder exists.

I need the position of a field in a resource to retrieve the field’s settings/content in a snippet. The cbGetFieldContent Snippet is using the field id, which could be problematic in cases where I use a field multiple times in a resource.

[[+Unique_idx]] is something similiar, but since its increasing with each layout as well, it is not whats needed here.