Add an index CSS class to cells
Hi,
I created this little piece of code there …
function msk_pagebuilder_add_cell_class($cell_attrs) {
$cell_index = 'panel-grid-cell-' . substr($cell_attrs['id'], -1);
$cell_attrs['class'] .= ' ' . $cell_index;
return $cell_attrs;
}
add_filter('siteorigin_panels_row_cell_attributes', 'msk_pagebuilder_add_cell_class', 10, 1);… so grid cells now have a “panel-grid-cell-X” CSS class where X is the index of the cell in the row (starting 0).
I’m here to share this code, maybe it can be useful to some people.
But I’d also like to ask developers if there is a better way to get the cell index. As you can see, the only way I found is to get the cell generated ID ($cell_attrs['id']) and get the last letter of this string. A bit dirty IMHO.
Any idea to do this properly ? I tried to get global variables for the foreach index but can't seem to figure out.
Thanks !
This is our free support forum. Replies can take several days.
Need fast email support? Get SiteOrigin Premium
Replies
3cf http://img.saika.li/ZrCb for the DOM result
Hi Pierre,
Thank you for sharing you code with us and also helping other people who might want to use this in their site. We really appreciate it :)
I am going to pass this to the developers to look on to this.
Thank you.
Thank you.
Replies on this thread are closed.
Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.