When editing a block and saving changes, is it normal to have a new entry in its table created?
Permalink
I created a block using the excellent Designer Content add-on.
I place the block on a page, edit it, save it. If I check the corresponding db table, there is a new entry (incremented id) that has the information of my edited block.
I had not noticed this behavior before. Has it always been there or is there something wrong with my block? Is this part of how versioning works?
I place the block on a page, edit it, save it. If I check the corresponding db table, there is a new entry (incremented id) that has the information of my edited block.
I had not noticed this behavior before. Has it always been there or is there something wrong with my block? Is this part of how versioning works?
OK that makes sense I must not have noticed it before. Thanks Andrew!
I also use the Designer Content add-on and it populates the btDCNews table just fine.
Then I need to get these entries to promote them on my homepage. So I access the DB, select the appropriate table and print the entries titles using the following code:
But I end up with a list of all the versions of ALL the entries titles!
How is it possible to know which one is the current (last) version of each entry?
Could anyone point me in the right direction?
Then I need to get these entries to promote them on my homepage. So I access the DB, select the appropriate table and print the entries titles using the following code:
$rs = $db->query('SELECT * FROM btDCNews'); while($row = $rs->fetchRow()) { echo $row['field_2_textbox_text'].'<br />'; }
But I end up with a list of all the versions of ALL the entries titles!
How is it possible to know which one is the current (last) version of each entry?
Could anyone point me in the right direction?
This question has been answered by Jordan on the "Designer Content" forums:
http://www.concrete5.org/marketplace/addons/designer-content/forums...
http://www.concrete5.org/marketplace/addons/designer-content/forums...
I also found out about the bID getting incremented and it now makes sense to me.
The only problem I got is, I have a which inserts a block on the header. The problem is when I edit and save a block the bID gets incremented while the gets left behind.
Ex.
Initially $bID = 76
This is my div
Header is:
After edit->save
$bID is incremented, hence $bID = 77
Div block style id gets updated
But the problem is the header style does not get incremented.
Here is my controller.php
The only problem I got is, I have a
$this->addHeaderItem($this->buildCss())
<style>#style-{$bID}</style>
<style>#style-{$bID}</style>
Ex.
Initially $bID = 76
This is my div
<div id="style-76"</div>
Header is:
<style>#style-76{}</style>
After edit->save
$bID is incremented, hence $bID = 77
Div block style id gets updated
<div id="style-77"</div>
But the problem is the header style does not get incremented.
<style>#style-76{}</style>
Here is my controller.php
public function on_page_view() { $this->addHeaderItem($this->buildCSS()); } public function buildCSS(){ $content = '#style-'.$this->bID.'{}'; return $content; }
Deleting blocks or old versions of pages with old blocks on them will remove this data, but unless the block is deleted in all versions where it appears, it'll keep its data around.