SpinaCMS / Spina

Spina CMS
http://www.spinacms.com
Other
2.19k stars 405 forks source link

Incorrect Structure Part content displayed on backend #254

Closed JimmyAustin closed 7 years ago

JimmyAustin commented 7 years ago

At the moment the name of each structure item displayed on the backend will change randomly. Basically if you have a structure with 3 different parts (say, name, description and date), the side selector for the structure will choose 3 different random parts to use on the sidebar. This looks like it might be due to line 12 in _form.html.haml

= structure_item.structure_parts.first.try(:structure_partable).try(:content) + 'test'

The structure parts will return in a random order from the database, so getting the first of the array will return a random object. A hacky fix can be implemented by adding in a order like so

 = structure_item.structure_parts.order("created_at asc").first.try(:structure_partable).try(:content) + 'test'

But ideally it should look at the structure definition in the theme initializer and use the content of the first path.

Let me know if you need any clarification.

Bramjetten commented 7 years ago

It currently tries to get the content of the very first structure partable that's created. Often this is a Spina::Line. The build_structure_parts method in pages_helper.rb initializes all these parts in the order of the theme initializer. We should probably look for a way to do the same for the name of each structure item.